Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

setting HTTP_PROXY #120

Closed
atomotic opened this issue Feb 23, 2018 · 2 comments
Closed

setting HTTP_PROXY #120

atomotic opened this issue Feb 23, 2018 · 2 comments

Comments

@atomotic
Copy link

atomotic commented Feb 23, 2018

process.env.HTTP_PROXY is not being passed to puppeteer.launch(), tried with a running proxy and:

env HTTP_PROXY=localhost:8000 node crawl.js

@yujiosaka
Copy link
Owner

@atomotic
Thanks for filing an issue!
I see puppeteer's document confusing. I read puppeteer's code and I found it uses HTTP_PROXY for downloading Chromium but not for running it.

Actually, it provides another way of using a proxy in this example.

headless-chrome-crawler passes args option to puppeteer when launching and connecting to a Chromium instance.
So it should work in this way:

const HCCrawler = require('headless-chrome-crawler');

HCCrawler.launch({
  args: [ '--proxy-server=127.0.0.1:3128' ], // Pass proxy setting here
  onSuccess: (result => {
    console.log(`Requested ${result.options.url}.`);
  }),
})
  .then(crawler => {
    crawler.queue('https://example.com/');
    crawler.onIdle()
      .then(() => crawler.close());
  });

@atomotic
Copy link
Author

good, thank you!
passing proxy in args works fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants