web-scraping-language

ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host - getting this error

馋奶兔 提交于 2021-01-29 16:35:54
问题 ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host I am getting this error while reading a webpage in the following code from urllib.request import urlopen as uReq from bs4 import BeautifulSoup as soup myurl = 'https://www.amazon.in/s?k=graphics+card&ref=nb_sb_noss_2' uClient =uReq(myurl) 回答1: passing a useragent header seems to solve the issue. try something like this: from urllib.request import urlopen as uReq, Request from bs4 import