简体   繁体   English

Python 网络抓取错误('连接中止',OSError(“(10060,'WSAETIMEDOUT')”))

[英]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.

相关问题 Python ConnectionError: ('Connection aborted.', OSError(“(10060, 'WSAETIMEDOUT')”)) - Python ConnectionError: ('Connection aborted.', OSError(“(10060, 'WSAETIMEDOUT')”)) 请求超时错误 (requests.exceptions.ConnectionError: ('Connection aborted.', OSError("(10060, 'WSAETIMEDOUT')"))) - Requests Timeout Error (requests.exceptions.ConnectionError: ('Connection aborted.', OSError("(10060, 'WSAETIMEDOUT')"))) 使用 python 请求获取 ('Connection aborted.', OSError(0, 'Error') 错误 - Getting ('Connection aborted.', OSError(0, 'Error') errors with python requests 如何在 Python 中跳过“Connection aborted.”、OSError(0, 'Error')? - How can I skip 'Connection aborted.', OSError(0, 'Error') in Python? Python-requests [('连接中止。', TimeoutError(10060) ] - Python-requests [('Connection aborted.', TimeoutError(10060) ] python - requests.get(连接中止。',OSError(“(60,'ETIMEDOUT') - python - requests.get (Connection aborted.', OSError("(60, 'ETIMEDOUT') 在 Azure ML 中获取 ('Connection aborted.', OSError(0, 'Error')) - getting ('Connection aborted.', OSError(0, 'Error')) in Azure ML 如何修复“连接中止”。 使用 BeautifulSoup 在 Python 中出错 - How to fix 'Connection aborted.' error in Python with BeautifulSoup Python: requests.exceptions.ConnectionError: ('Connection aborted.', OSError(“(54, 'ECONNRESET')”,)) - Python: requests.exceptions.ConnectionError: ('Connection aborted.', OSError(“(54, 'ECONNRESET')”,)) Python-请求lib-错误(“连接已中止。”,BadStatusLine(“''”,)) - Python - requests lib - error ('Connection aborted.', BadStatusLine(“''”,))
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM