最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

javascript - How to use proxy in NodeJS Selenium? - Stack Overflow

programmeradmin0浏览0评论

In the documentation, I read that for using proxy set while building driver like this:

var driver = new webdriver.Builder()
    .withCapabilities(webdriver.Capabilities.chrome())
    .setProxy(proxy.manual({http: 'host:1234'}))
    .build();

When I use this code with proxy '103.87.16.2:80' - .setProxy(proxy.manual({http: 'host:1234'})), I still have my home IP.

What is the problem?

In the documentation, I read that for using proxy set while building driver like this:

var driver = new webdriver.Builder()
    .withCapabilities(webdriver.Capabilities.chrome())
    .setProxy(proxy.manual({http: 'host:1234'}))
    .build();

When I use this code with proxy '103.87.16.2:80' - .setProxy(proxy.manual({http: 'host:1234'})), I still have my home IP.

What is the problem?

Share Improve this question edited Mar 18, 2018 at 20:02 Omar Einea 2,5227 gold badges24 silver badges36 bronze badges asked Mar 18, 2018 at 19:37 chosiraichosirai 1931 gold badge3 silver badges7 bronze badges 1
  • The proxy works as expected. How are you determining the IP address in use? Also, please have a look at stackoverflow./questions/11450158/… and sites.google./a/chromium/chromedriver/capabilities – rollstuhlfahrer Commented Mar 25, 2018 at 20:13
Add a ment  | 

1 Answer 1

Reset to default 3
const { Builder } =  require('selenium-webdriver');
const chrome = require('selenium-webdriver/chrome');

let proxyAddress = '212.56.139.253:80'
// Setting the proxy-server option is needed to info chrome to use proxy
let option = new chrome.Options().addArguments(`--proxy-server=http://${proxyAddress}`)

const driver = new Builder()
  .forBrowser('chrome')
  .setChromeOptions(option)
  .build()

driver.get('http://whatismyip.host/')
  .then(() => console.log('DONE'))
发布评论

评论列表(0)

  1. 暂无评论