【发布时间】:2020-11-11 06:46:19
【问题描述】:
上面的url是get request Url,下面是我的python代码
import requests
url = "https://www.nseindia.com/api/corporates-pit?index=equities&from_date=21-04-2020&to_date=21-07-2020&csv=true"
payload = {}
headers= {}
response = requests.request("GET", url, headers=headers, data = payload)
print(response.text.encode('utf8'))
我也试过http.client
import http.client
import mimetypes
conn = http.client.HTTPSConnection("www.nseindia.com")
payload = ''
headers = {}
conn.request("GET", "/api/corporates-pit?index=equities&from_date=21-04-2020&to_date=21-07-2020&csv=true", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
错误/秒
urllib3.exceptions.ProtocolError: ('Connection aborted.', TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', None, 10060, None))
During handling of the above exception, another exception occurred:
raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', TimeoutError(10060, 'A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond', None, 10060, None))
【问题讨论】:
标签: python python-3.x csv python-requests postman