Download web pages and files from the internet using CLI or as a Python module.
Project description
net-dl
Download web pages and files from the internet. Can be used as a standalone CLI command, or as a python module.
Installation
End Users (with pipx)
python3 -m pip install pipx
pipx install net-dl
Dev Users (with pip)
python3 -m pip install net-dl
Usage
CLI command
~$ # print content to stdout if text/html/json/xml
~$ net-dl 'https://httpbin.org/json'
{
"slideshow": {
"author": "Yours Truly",
"date": "date of publication",
"slides": [
{
"title": "Wake up to WonderWidgets!",
"type": "all"
},
{
"items": [
"Why <em>WonderWidgets</em> are great",
"Who <em>buys</em> WonderWidgets"
],
"title": "Overview",
"type": "all"
}
],
"title": "Sample Slide Show"
}
}
~$ # save content to disk if file
~$ net-dl 'https://httpbin.org/image/svg'
[................................... ] 50%
Python module
Built-in progress bar
>>> import net_dl
>>> url = 'https://httpbin.org/image/svg'
>>> dl = net_dl.Download(url)
>>> dl.get()
[........................................................................] 100%
0
>>> import logging
>>> l = logging.get_logger()
>>> l.setLevel(logging.INFO)
>>> dl.get()
INFO:root:File already exists: /home/nate/g/net-dl/svg
0
>>>
External progress bar
demo/tkapp.py
:
from net_dl import Download
from queue import Queue
from threading import Thread
from tkinter import IntVar
from tkinter import StringVar
from tkinter import Tk
from tkinter import ttk
class Win(ttk.Frame):
def __init__(self, root):
super().__init__(root)
self.root = root
self.root.title("net-dl demo")
self.urlv = StringVar()
self.urlw = ttk.Entry(self, textvariable=self.urlv)
self.getw = ttk.Button(self, text="Get", command=self.get)
self.progq = Queue()
self.progv = IntVar()
self.proge = '<<UpdateProgress>>'
self.root.bind(self.proge, self.update_progress)
self.progw = ttk.Progressbar(
self,
mode='determinate',
variable=self.progv,
)
self.grid(column=0, row=0, sticky='nesw')
self.urlw.grid(column=0, row=0, columnspan=4, sticky='we')
self.getw.grid(column=4, row=0)
self.progw.grid(column=0, row=1, columnspan=5, sticky='we')
def get(self):
dl = Download(
self.urlv.get(),
progress_queue=self.progq,
callback=self.root.event_generate,
callback_args=[self.proge],
)
self.get_thread = Thread(target=dl.get, daemon=True)
self.get_thread.start()
def update_progress(self, evt):
self.progv.set(self.progq.get())
def run():
root = Tk()
Win(root)
root.mainloop()
Run code:
demo$ python -c 'import tkapp; tkapp.run()'
Releasing on PyPI
- Create new tag in repo that matches package version; e.g. if version is "0.1.0", tag will be "v0.1.0".
- CI will auto build and upload package to TestPyPI and PyPI.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file net_dl-0.1.5.tar.gz
.
File metadata
- Download URL: net_dl-0.1.5.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e024b4a0369e4e071b06c8f2f35ec21e17aa0bd6e7fecdd6fbcf610647e8f5df |
|
MD5 | 0ed1df50fe3246256d93432732050a59 |
|
BLAKE2b-256 | 70e47ed1d57dc5638ca7f369f26440ee41c3fb2c6cc054f91b7427c960f5dced |
Provenance
The following attestation bundles were made for net_dl-0.1.5.tar.gz
:
Publisher:
publish.yml
on sil-car/net-dl
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
net_dl-0.1.5.tar.gz
- Subject digest:
e024b4a0369e4e071b06c8f2f35ec21e17aa0bd6e7fecdd6fbcf610647e8f5df
- Sigstore transparency entry: 148642864
- Sigstore integration time:
- Predicate type:
File details
Details for the file net_dl-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: net_dl-0.1.5-py3-none-any.whl
- Upload date:
- Size: 10.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.12.7
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e793efa57d062fd4246281db61f810dd7f9f1f8dd685f2f67fcf82837fcba095 |
|
MD5 | e17a988ee1a11b35863c72d541fade97 |
|
BLAKE2b-256 | c6e8ea2f4e791436832bc6e077419d48b8b0a73c818fdaf0740a4115419ed404 |
Provenance
The following attestation bundles were made for net_dl-0.1.5-py3-none-any.whl
:
Publisher:
publish.yml
on sil-car/net-dl
-
Statement type:
https://in-toto.io/Statement/v1
- Predicate type:
https://docs.pypi.org/attestations/publish/v1
- Subject name:
net_dl-0.1.5-py3-none-any.whl
- Subject digest:
e793efa57d062fd4246281db61f810dd7f9f1f8dd685f2f67fcf82837fcba095
- Sigstore transparency entry: 148642866
- Sigstore integration time:
- Predicate type: