Egg: httpclient 怎么像request 一样设置proxy 代理 做爬虫需要请求代理

Created on 30 Jun 2017  ·  7Comments  ·  Source: eggjs/egg

  • Node Version:
  • Egg Version:
  • Plugin Name:
  • Plugin Version:
  • Platform:
  • Mini Showcase Repository:

Most helpful comment

官网现在有个坑在egg官方的quickstart里面,挂载在ctx的curl请求url是需要vpn的,并且需要在请求的option中设置
enableProxy: true,
proxy: 'http://127.0.0.1:1087'

还得先在shell里面配置 export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;

All 7 comments

官网现在有个坑在egg官方的quickstart里面,挂载在ctx的curl请求url是需要vpn的,并且需要在请求的option中设置
enableProxy: true,
proxy: 'http://127.0.0.1:1087'

还得先在shell里面配置 export http_proxy=http://127.0.0.1:1087;export https_proxy=http://127.0.0.1:1087;

请求是否需要 VPN 取决于你自己的网络环境,何来坑这一说

不是每个公司都是外资默认就是墙外的,是坑就得承认。

你请求才需要代理,其他人不需要代理。要不要代理与自己的环境相关,难道要求所有文档请求外部网站都需要加配置代理?

我意思是在请求 https://hacker-news.firebaseio.com/v0/topstories.json 的时候需要去配置代理,这块自己有vpn才知道需要翻墙才能看到返回信息,不然就返回一个502,才明白要设置代理这块绕了好久。看cnode上面一个老哥给的方案说解决了完全不是这么回事都没设置允许代理奇怪他怎么跑通的。

Was this page helpful?
0 / 5 - 0 ratings