'Connection aborted.'when using requests

415 Views Asked by At
import requests
url = 'http://femhzs.mofcom.gov.cn/fecpmvc/pages/fem/CorpJWList_nav.pageNoLink.html;jsessionid=8C736597A2750E8A4D32363D15A9A5DF?session=T&sp=1&sp=S+_t1.CORP_CDE%2C+_t1.id&sp=T&sp=S'
headers = { 'User-Agent': "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36"}
r = requests.get(url,headers = headers)

My code is shown above, while this get an connection aborted error. What should I do, need some help.

1

There are 1 best solutions below

3
aydow On

Your URL doesn't work but you're using everything in the correct way

In [168]: url = 'https://www.google.com'

In [169]: response = requests.get(url, headers=headers)

In [170]: response.status_code
Out[170]: 200