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

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

Downloads a file via HTTP/HTTPS.

Parameters:
  • url (str) – URL to download
  • save (bytes, str, 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://httpbin.org/robots.txt'
>>> result = wget(url)
>>> result
b'User-agent: *\nDisallow: /deny\n'
>>> result2 = wget(url, True)
>>> result == open('robots.txt', 'rb').read()
True