Reputation: 1915
I am using Python 3.7.3 and I'm trying to GET a gif:
import requests
requests.get("https://track.hubspot.com", allow_redirects=True)
This code hangs, apparently indefinitely.
import requests
requests.get("https://track.hubspot.com", allow_redirects=True, timeout=0.1)
This code throws an error in read: ReadTimeout: HTTPSConnectionPool(host='track.hubspot.com', port=443): Read timed out. (read timeout=0.1)
If I visit it in my browser, I successfully load the 1x1 gif at the target. urllib3
and wget
(the command-line tool, not the Python library) also hang. Is there a way to use Python to GET the address without the arbitrary timeout and the error?
Upvotes: 0
Views: 1310
Reputation: 423
This works for me response = requests.get('https://track.hubspot.com')
You should consider using a context manager.
with requests.Session() as session:
response = session.get("https://track.hubspot.com")
Upvotes: 1