-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathproxy.js
34 lines (27 loc) · 1.03 KB
/
proxy.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
require('chromedriver');
// require('dotenv').config();
// Replace this import with `require('..')` if you are running the example from the repository:
const { plugin } = require('selenium-with-fingerprints');
const { Options } = require('selenium-webdriver/chrome');
const { Builder, until, By } = require('selenium-webdriver');
// The default proxy value is just an example, it won't work.
const proxy = process.env.FINGERPRINT_PROXY ?? 'socks5://127.0.0.1:9762';
(async () => {
plugin.useProxy(proxy, {
detectExternalIP: false,
changeGeolocation: true,
});
const driver = await plugin.launch({
builder: new Builder().setChromeOptions(
new Options().addArguments([
// This argument will be ignored if the `useProxy` method has been called.
`--proxy-server=${proxy}`,
'--headless',
])
),
});
await driver.get('https://canhazip.com/');
const pre = await driver.wait(until.elementLocated(By.css('pre')));
console.log('External IP:', await pre.getText());
await driver.quit();
})();