Unable to connect with proxy server
See original GitHub issueComponent | Version |
---|---|
Operating system | win 10 |
Node.js | 12.16.1 |
Chrome/Chromium/… | Chrome 87 (latest), using Chrome Launcher 0.13.4 |
chrome-remote-interface | 0.28.2 |
Is Chrome running in a container? YES / NO
Attempting to connect to webpages through a free proxy server, using sites like:
https://www.proxynova.com/proxy-server-list http://www.freeproxylists.net/ https://free-proxy-list.net/
For this I’ve been using Chrome Launcher to set up the headless chrome instance, and then some really basic chrome remote interface stuff to test that the IP address has changed. I’m checking my IP address of the headless chrome instance using this website https://whatismyipaddress.com/. Following similarly to https://www.youtube.com/watch?v=wAyocwixpFA.
Code that I’m using to connect, use proxy and check IP
const chromeLauncher = require("chrome-launcher");
const CDP = require("chrome-remote-interface");
const proxy = "--proxy-server=PROXY_IP:PROXY_PORT";
(async function() {
// launch chrome running on debug port 9222 (for chrome-remote-interface), with headless and proxy flags
let chrome = await chromeLauncher.launch({
port: 9222,
chromeFlags: ["--disable-gpu", "--headless", "--enable-logging", proxy]
});
let client = await CDP();
let Page = client.Page;
await Page.enable();
let Runtime = client.Runtime;
await Runtime.enable();
// go to website and wait until page has loaded
await Page.navigate({ url: "https://whatismyipaddress.com/"});
await Page.loadEventFired();
// scrape IP address from website
const { result: { value }} = await Runtime.evaluage({
expression: "document.querySelectorAll('#ipv4 > a')[0].innerHTML;"
});
// return the scraped ip address eg; (255.255.255.255)
console.log("IP Address:", value);
})();
In this case with and without using the chrome flag --proxy-server=PROXY_IP:PROXY_PORT
, I always retrieve my IP address, and never get the address of any of the proxy servers. I’ve also tried different variations of the --proxy-server option: You can find the three here https://www.chromium.org/developers/design-documents/network-settings#TOC-Command-line-options-for-proxy-settings
–proxy-server=PROXY_IP:PROXY_PORT eg; (–proxy-server=255.255.255.255:8080) –proxy-server=SCHEME=PROXY_IP:PROXY_PORT eg; (–proxy-server=https=255.255.255.255:8080) –proxy-server=LINK_TO_PROXY eg; (https://255.255.255.255:8080)
I’ve tried all of these, including adding the “double quotes” around the values, and all have given me the same result, I’ve also tried using a random string (in attempt to get an error) for the proxy ip, and again get the same result. I’m not sure whether this is a chrome-launcher issue or a chrome-remote-interface issue either. In any case, I never recieve an error from chrome-launcher or chrome-remote-interface, and the script just spits out my IP address.
Any help with this would be greatly appreciated, if you need any more information I can provide this asap.
EDIT: For anyone with the same issue, I was able to solve this issue using --proxy-server=PROXY_IP:PROXY_PORT eg; ( --proxy-server=255.255.255.255:8080 )
, and the security code provided below by cyrus-and. I would sugest using a free proxy for testing from http://www.freeproxylists.net/, atleast proxies from there worked for me
Issue Analytics
- State:
- Created 3 years ago
- Comments:14 (7 by maintainers)
Top GitHub Comments
Sorry for the late reply, here you go, this should work:
Exactly what I was looking for, thank you again for the assistance