写了一个小爬虫 遇到了两个关于 requests 和 openssl 的问题

2016-12-21 14:30:17 +08:00
 Anhedonia
最近想写一个爬虫 用来去 ehentai 爬本子玩
结果发现 requests.get 这个方法在爬 url 的时候会报错

requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))

在网上查了一下 有人说是关于 OS X 自带的 openssl 版本太旧的关系
于是用 homebrew 去更新 openssl 结果在 link 的时候又爆出了错误
Linking keg-only openssl means you may end up linking against the insecure,
deprecated system OpenSSL while using the headers from Homebrew's openssl.
Instead, pass the full include/library paths to your compiler e.g.:
-I/usr/local/opt/openssl/include -L/usr/local/opt/openssl/lib

请问 1.requests 的问题跟 openssl 有关系么?
2.openssl 更新的问题怎么解决呀
10836 次点击
所在节点    Python
28 条回复
Ahri
2016-12-21 14:43:19 +08:00
你要把报错的 URL 以及 Python requests 版本发出来。
mansur
2016-12-21 14:49:34 +08:00
把 verify 这个参数设置为 false 试试
402124773
2016-12-21 16:06:59 +08:00
如果只是想解决该问题,让爬虫正常工作,可以用 try catch 忽略这个错误,继续运行。
Anhedonia
2016-12-21 16:46:47 +08:00
@402124773 可是我要爬的就是这个页面啊
如果忽略了的话 那就爬不下来东西了呀
402124773
2016-12-21 17:05:00 +08:00
@Anhedonia
我以前的爬虫中出现过
requests.exceptions.ConnectionError: ('Connection aborted.', error(104, 'Connection reset by peer'))
但是出现时概率性的,并且概率很低,我就了循环和 try catch 忽略,然后就可以了
annielong
2016-12-21 17:12:46 +08:00
爬虫抓 ssl 不同环境总会有多多少少的问题,一样的 py 环境, win2008 就出问题, win7 没问题,
Anhedonia
2016-12-21 17:43:39 +08:00
@402124773 可是你是 104 我是 54 诶
julyclyde
2016-12-21 19:50:27 +08:00
问题是这跟 ssl 根本没关系啊
Anhedonia
2016-12-21 21:34:21 +08:00
@julyclyde 这就尴尬了
Anhedonia
2016-12-21 21:36:34 +08:00
@Ahri http://g.e-hentai.org/g/1007888/4e17fb376c/
随便 ehentai 上拿了个本子(无声发车

诺 就是爬不下来
Ahri
2016-12-21 22:35:39 +08:00
@Anhedonia 要你出错的 URL ,没人有时间在那慢慢找。 How To Ask Questions The Smart Way http://www.catb.org/~esr/faqs/smart-questions.html
Anhedonia
2016-12-21 22:41:52 +08:00
@Ahri 这个就出错了
realityone
2016-12-21 23:01:02 +08:00
你是不是没翻墙就爬了啊
Ahri
2016-12-21 23:29:16 +08:00
@Anhedonia 你这个不是 HTTPS ,跟 SSL 无关
Yinz
2016-12-22 01:28:02 +08:00
像是被反爬虫 reset 了连接?
Sylv
2016-12-22 05:01:42 +08:00
如果不是 https 的话和 openssl 没关系,出现 'Connection reset by peer' 错误大部分情况下是爬虫没有伪装好或者请求太频繁被网站服务器拒绝访问了。
Anhedonia
2016-12-22 06:32:41 +08:00
@realityone 翻了呀
终端也做了代理了
Anhedonia
2016-12-22 07:40:40 +08:00
@Yinz
@Sylv
UA cookie referee 全都做了 还是这么报错
Sylv
2016-12-22 08:10:07 +08:00
@Anhedonia 我这边什么都没设直接就能 get 200 成功,不过我是在国外,所以可能是墙或代理的锅。
Anhedonia
2016-12-22 08:37:51 +08:00
@Sylv 好吧 我尝试重新设置一下代理试试

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/329155

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX