IP address of the current browser
Maybe someone has an idea of how to get the IP address of the current puppeteer browser instance that is using a proxy?
Is there another way than going to a "whats my IP page" and scraping it?
8 Replies
@liutc just advanced to level 2! Thanks for your contributions! 🎉
You may use single request (got, axios, fetch, ...) and set the same proxy to save some resources. But no, if you use a proxy groups there is no way how to obtain the IP without calling another service that will return it for you.
What about printing the proxy configuration ?
frozen-sapphireOP•3y ago
Proxy is connecting to another URL and that URL selects an IP randomly 🙂
This is my solution for now:
const sessionIpAddress = await page.evaluate(async () => {
const ipGetResponse = await fetch('https://get.geojs.io/v1/ip/geo.json');
ipObject = await ipGetResponse.json();
return ipObject.ip;
});
@liutc If you are using simple fetch like that, it doesn't use proxy at all, it uses the single IP from the datacenter when the Actor is running. I suggest to use Axios ot Got with proper HttpAgent settings.
frozen-sapphireOP•3y ago
@Pepa J but it seems it works? Im getting a different IP every time
@liutc Ah, sorry just noticed you using it in
page.evalue
which means it would be evaluated in the browser which has the proxy already set, so not further configuration is needed.frozen-sapphireOP•3y ago
Yup:)