scrapy 代理好奇怪

2017-05-18 13:19:35 +08:00
 HGladIator
取消代理没问题 能慢慢爬
用上代理后全部超时 超时设 15s
单独把所有代理 ip 测试一遍,没问题(超时设 5s )
有问题的之前找到直接全删了





我怀疑我的检测有问题
就乱编了一个代理 ip
结果


所以到现在我还不明白哪里出了问题
2097 次点击
所在节点    Python
18 条回复
panyanyany
2017-05-18 13:40:52 +08:00
https 的请求应该不会经过 http 代理的吧
HGladIator
2017-05-18 13:45:01 +08:00
@Jessss
@yxy2829

看到你们也在用 帮我看看呗 谢谢啦
freeminder
2017-05-18 13:48:38 +08:00
你拿 http 的代理,怎么代理 https 的流量。
HGladIator
2017-05-18 13:51:45 +08:00
@freeminder #3
@panyanyany #1
所以要用 https 的么
freeminder
2017-05-18 13:59:42 +08:00
HGladIator
2017-05-18 14:10:35 +08:00
@freeminder #5 是不是代理设置无效 会用本地的代替? 我随便设的代理 都可以收到响应
freeminder
2017-05-18 14:26:07 +08:00
@HGladIator 说了你随便写的那个代理根本没生效,因为你设置了 http 请求的代理, 发了一个 https 的请求出去。你把 proxies 那个字段的 https 的 key 也配置成 http 的 key 就知道了
HGladIator
2017-05-18 14:34:11 +08:00
@freeminder #7 恩 我配了 好多失败的 我再试试
pango
2017-05-18 15:05:23 +08:00
proxies = { "http": "http://x.x.x.x:xx", "https": "http://x.x.x.x:xx", }
就行了
HGladIator
2017-05-18 15:23:02 +08:00
@pango #9 scrapy 那个 proxy 不能是 dict 的 会报错 我试过
pango
2017-05-18 15:50:17 +08:00
@HGladIator 你不是在 requests 中用了 proxy 吗?如果是 scrapy 的话不存在 http,https 代理的问题的
HGladIator
2017-05-18 15:52:42 +08:00
@pango #11 你看第一个张图 这里的是 http 然后全部超时
pango
2017-05-18 15:53:52 +08:00
另外明确一下: http 的代理服务器是可以代理 https 的流量的,https 走 http 代理通过的是隧道,对流量本身没有任何影响。

requests 的 proxies = { "http": "http://x.x.x.x:xx", "https": "http://x.x.x.x:xx", }只是用来说明 http,https 分别走哪个代理服务器,但他们走的都可以是同一个 http 代理。
HGladIator
2017-05-18 15:57:23 +08:00
@HGladIator #12 谢谢你的解惑
pango
2017-05-18 16:06:15 +08:00
@HGladIator get_invalid_proxies 和 test_proxies 两个 def 里面你定义了 requests 的 http 流量走 proxy,就像这样子:{ "http": "http://x.x.x.x:xx"},但是接下来却去 get 了一个 https 的网站,这个 https 的网站根本没走任何代理....
估计还是你的代理有问题,你还是按照这个格式: proxies = { "http": "http://x.x.x.x:xx", "https": "http://x.x.x.x:xx", } 来用 requests 测试你的代理吧。
HGladIator
2017-05-18 16:16:34 +08:00
已经改了 跑了两个小时了 还没跑完 绝大部分都是无效的
HGladIator
2017-05-18 16:17:15 +08:00
@pango #15 已经改了 跑了两个小时了 还没跑完 绝大部分都是无效的
BiggerLonger
2017-05-18 17:03:12 +08:00
proxy = {'http': 'http://' + ip} ===========> proxy = {'http': ip} ?

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

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

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

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

© 2021 V2EX