Python client error 'Connection reset by peer'

↘锁芯ラ 提交于 2019-11-29 04:01:31

While installing requests library it skips few of optional security packages ('pyOpenSSL', 'ndg-httpsclient', and 'pyasn1') which are required for the SSL/Https connection. You can fix it by either running this command

pip install "requests[security]"

or

pip install pyopenssl ndg-httpsclient pyasn1

I tried installing all the optional security packages provided in the answer above. But nothing seemed to work.

One important GOTCHA : Check if your url end-point actively prevents programmatic access.

Take a look at the robots.txt file in the root directory of a website: http://myweburl.com/robots.txt.

If it contains text that looks like this : User-agent: * Disallow: /

This site doesn’t like and want scraping. This gives you the same dreaded error 54, connection reset by the peer.

Here is a snapshot :

https://www.aclibrary.org/robots.txt

User-agent: discobot Disallow: / User-agent: AddThis.com Disallow: / User-agent: Yandex Disallow: / User-agent: Baiduspider Disallow: / User-agent: Baiduspider-video Disallow: / User-agent: Baiduspider-image Disallow: / User-agent: SemrushBot Disallow: / User-agent: SemrushBot-SA Disallow: / User-Agent: W3C-checklink Crawl-delay: 0 User-agent: Twitterbot Disallow: User-agent: * Crawl-delay: 10 Disallow: /er.php Disallow: /err.php Disallow: /go.php Disallow: /friendly.php Disallow: /ld.php Disallow: /srch.php Sitemap: https://aclibrary.org/sitemap.xml

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