Webscraping with Python: WinError 10061: Target machine actively refused

微笑、不失礼 提交于 2019-12-24 13:42:41

问题


I am writing a code to scrape data from a website. The code was working fine until I decided to hide my IP address. I get the following error "urlopen error [WinError 10061] No connection could be made because the target machine actively refused it"

I have disabled the firewalls and antivirus on my machine; Tor is installed and running, internet connection is fine (obviously). Could someone help me figure out where the problem is? And whether it can be fixed (I cannot change the website I am scraping data from.)?

Here is the code:

list_url= ["http://www.url.com"]
proxy_support = urllib.request.ProxyHandler({"http":"http://127.0.0.1:8118"})  
opener = urllib.request.build_opener(proxy_support)  
urllib.request.install_opener(opener)

for url in list_url:
 base_url_parts = urllib.parse.urlparse(url)
 while True:
    raw_html = urllib.request.build_opener(proxy_support).open(url).read()
...

来源:https://stackoverflow.com/questions/29271180/webscraping-with-python-winerror-10061-target-machine-actively-refused

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!