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_get.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()'
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
net_dl-0.1.0.tar.gz
(10.9 kB
view details)
Built Distribution
net_dl-0.1.0-py3-none-any.whl
(10.1 kB
view details)
File details
Details for the file net_dl-0.1.0.tar.gz
.
File metadata
- Download URL: net_dl-0.1.0.tar.gz
- Upload date:
- Size: 10.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 01b8030c3ea1dab8c3be2811f5beae61efa9283ae94c57c327da7dc0ab71a20d |
|
MD5 | 902d21b53c29e46600a16e28fef93048 |
|
BLAKE2b-256 | d32aa9468507179c5d5f226c2a5b4121c28d1e2a8ed4da240c48548169332e64 |
File details
Details for the file net_dl-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: net_dl-0.1.0-py3-none-any.whl
- Upload date:
- Size: 10.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/5.1.1 CPython/3.13.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 00fb6210eb0ce464d96f4998f1c5b10b099ff6b1da959eb0359ab3e6e395b5a1 |
|
MD5 | 80c063a401ef8486a8a0f9e9a79aa8dd |
|
BLAKE2b-256 | 4adf1302388e3fa20908374ed9eb10d1ee14875a87aa34f9505762417b4646a4 |