I am attempting to access the url 'https://www.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=nasdaq&render=download' which downloads a CSV file. When I use urllib3 and send a 'GET' request, the code hangs and eventually produces an error. I can use urllib3 successfully on other url's I try though.
Using urlopen from urllib.request works perfectly, as well as the requests library with the get() method. How can I use urllib3 and why is it not working on this specific URL?
Python 3.7.3 urllib3 1.23.2 requests 2.22.0
I've tried reading urllib3 docs and using the urllib3 .urlopen instead of .request method but neither works.
import requests
from urllib.request import urlopen
from urllib3 import PoolManager
url='https://www.nasdaq.com//screening//companies-by-name.aspx?letter=0&exchange=nasdaq&render=download'
# USING urllib3
http=PoolManager()
page=http.request('GET', url)
#USING urllib
page=urlopen(url)
#USING requests
page=requests.get(url)
I expect a response but using urllib3 I get this error after about 1 minute:
raise MaxRetryError(_pool, url, error or ResponseError(cause))
urllib3.exceptions.MaxRetryError: HTTPSConnectionPool(host='www.nasdaq.com', port=443): Max retries exceeded with url: //screening//companies-by-name.aspx?letter=0&exchange=nasdaq&render=download (Caused by ProtocolError('Connection aborted.', OSError("(10060, 'WSAETIMEDOUT')")))
# see: https://www.nasdaq.com/robots.txt
import urllib3
url='https://www.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=nasdaq&render=download'
user_agent = {'user-agent': 'Mozilla/5.0 (Windows NT 6.3; rv:36.0) ..'}
http = urllib3.PoolManager(10, headers=user_agent)
http.urlopen('GET', url)