Parag
Parag

Reputation: 345

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. 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.

Thanks

Upvotes: 0

Views: 535

Answers (1)

Gerardsson
Gerardsson

Reputation: 382

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.

The WSAETIMEDOUT error means that the connected party did not properly respond after a period of time.

Upvotes: 1

Related Questions