Skip to main content

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.

Project README

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

net_dl-0.1.2.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

net_dl-0.1.2-py3-none-any.whl (10.3 kB view details)

Uploaded Python 3

File details

Details for the file net_dl-0.1.2.tar.gz.

File metadata

  • Download URL: net_dl-0.1.2.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for net_dl-0.1.2.tar.gz
Algorithm Hash digest
SHA256 1854fdd44d75821f600bb7bc0cb3c5b6418545475c5470ed5f31408991f6f0b5
MD5 ddd05b6abbb8e1f0407b63340653f864
BLAKE2b-256 fe4dd54f401412f364dab087121280675d35fd4ea4252706155282a1fe56e590

See more details on using hashes here.

File details

Details for the file net_dl-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: net_dl-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 10.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.13.0

File hashes

Hashes for net_dl-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 0870607509454d245c533042c52debc92d77818c6811fbf013e898cc5a149510
MD5 445caacfd35f108badb4fafc3837225b
BLAKE2b-256 a47274520a823c2ae56f8fd82a1e7eebebf023d91796ece5e70af08640563bac

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page