[英]Python Webscraping Error ('Connection aborted.', OSError(“(10060, 'WSAETIMEDOUT')”))
I am using Python 3.X to extract data from website in Jupyter Notebook using Opera version 67.0.3575.137.我正在使用 Python 3.X 使用 Opera 版本 67.0.3575.137 从 Jupyter Notebook 中的网站提取数据。 Following is a simple code
下面是一个简单的代码
import requests
import json
import pandas as pd
from datetime import datetime
from datetime import timedelta
pd.options.display.float_format = '{:20,.2f}'.format
pd.set_option('display.max_colwidth', None)
import numpy as np
url="https://www.nseindia.com/market-data/exchange-traded-funds-etf"
headers = { "User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.163 Safari/537.36 OPR/67.0.3575.137"}
r=requests.get(url, headers=headers)
r.status_code
# df1=pd.DataFrame().from_records(r['data'])
But i am getting following error但我收到以下错误
C:\ProgramData\Anaconda\lib\site-packages\requests\adapters.py in send(self, request, stream, timeout, verify, cert, proxies)
496
497 except (ProtocolError, socket.error) as err:
--> 498 raise ConnectionError(err, request=request)
499
500 except MaxRetryError as e:
ConnectionError: ('Connection aborted.', OSError("(10060, 'WSAETIMEDOUT')"))
Kindly help to resolve this issue as could not make it out why it is giving an error while same URL https://www.nseindia.com/market-data/exchange-traded-funds-etf is working fine in a browser.请帮助解决此问题,因为无法弄清楚为什么它会给出错误,而相同的 URL https://www.nseindia.com/market-data/exchange-traded-funds-etf在浏览器中工作正常。
Thanks谢谢
I ran your code from my computer and it ran without an error.我从我的电脑上运行了你的代码,它运行没有错误。 I got a status_code=200 You should probably check the permission settings of the Jupyter notebook.
我得到了一个 status_code=200 你应该检查一下 Jupyter notebook 的权限设置。
The WSAETIMEDOUT error means that the connected party did not properly respond after a period of time. WSAETIMEDOUT 错误意味着连接方在一段时间后没有正确响应。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.