pwnlib.util.web — Utilities for working with the WWW

pwnlib.util.web.wget(url, save=None, timeout=5) str[source]

Downloads a file via HTTP/HTTPS.

Parameters
  • url (str) – URL to download

  • save (str or bool) – Name to save as. Any truthy value will auto-generate a name based on the URL.

  • timeout (int) – Timeout, in seconds

Example

>>> url    = 'https://httpbingo.org/robots.txt'
>>> result = wget(url, timeout=60)
>>> result
b'User-agent: *\nDisallow: /deny\n'
>>> filename = tempfile.mktemp()
>>> result2 = wget(url, filename, timeout=60)
>>> result == open(filename, 'rb').read()
True