Selenium finding ip address of chrome - python

I'm using a vpn and it only changes ip address of chrome. Sometimes my vpn connection goes down and I want to know when it happens and I want to be able to know that by comparing my local ip address and chromes ip address so that if they are equal I will know that my vpn connection is down.
Is there any possibility to see my chrome's ip address that selenium makes (using seleniums any function or without using doesn't matter)? I need to get that ip not just for only this case, that's why I don't use try catch.
Is there any way to find my chrome's ip address that selenium makes with VB 6.0 and with Python?

Related

Changing external IP address in Python

I have a python robot that accesses internet websites and performs some tasks (using selenium and google chrome). I would like make the python code to change my external IP address every, say, 10 interactions that the code performs in the websites. Is it possible? Would you have the adequate line of code for this task?
Note that the websites that I access recognize VPN, so when I try changing my IP address through VPN, I cannot access these websites.
Thank you

Page still get my IP although using Tor and Privoxy

I configured Tor browser and privoxy using https://jarroba.com/anonymous-scraping-by-tor-network/. When I checked my IP with http://icanhazip.com/, my IP addresses are changed; it works. But, when I tried to scrape desired website, I got:
You are attempting to access "website" using an anonymous private/proxy network. Please disable that and try accessing the site again.
Tor hides your IP address, but it does not hide the fact that you are using Tor, since Tor exit relays are public knowledge. For example, xmyip.com will tell you whether or not your IP is a Tor IP.
Given the error you received, it looks like that website blocks Tor users, which is a fairly common practice. See Tor users being actively blocked on some websites for more details.

How to connect my VPN with the python requests?

My IP is not changing after connecting to the VPN(NordVPN). Here's my code:
How can I fix this? I am noob in python please help by listing the step by step guide.
import requests
res=requests.get("https://httpbin.org/ip")
print(res.text)
I can't comment on this post so I'll just tell you that you should format code by surrounding it with backticks (this character: ` ). Also, please separate each line. Please update your post.
As for your question, please do understand that Python code is not necessary to check your IP address. Simply going to that web address in your browser should show you your IP. Moreover, if your IP address is not changing after enabling a VPN, your VPN is at fault, not Python. When I use a VPN and go to that address in the browser, it does work.
Finally, I suspect that you are using a NordVPN browser extension, not a system-wide VPN. In that case, Python is not actually going through your browser to access the web address. It is directly requesting the information from the webpage. If you install system-wide, it should work.

faking hostname in selenium

I'm trying to test response time of webpages hosted on many backends. These hosts are behind load balancer and above that I have my domain.com.
I want to use python+selenium on these backends but with spoofed hostname, without messing with /etc/hosts or running fake DNS servers. Is that possible with pure selenium drivers?
To illustrate problem better, here is what's possible in curl and I'd like to do the same with python+selenium:
If you're on a UNIX system, you can try something as explained here:
https://unix.stackexchange.com/questions/10438/can-i-create-a-user-specific-hosts-file-to-complement-etc-hosts
Basically you still use a hosts file, but it's only for you, located in ~/.hosts, setting the HOSTALIASESenvironment variable.
In short, no.
Selenium drives browsers using the WebDriver standard, which is by definition limited to interactions with page content. Even though you can provide Selenium with configuration options for the browser, no browser provides control over Host headers or DNS resolution outside of a proxy.
But even if you could initiate a request for a particular IP address with a custom Host header, subsequent requests triggered by the content (redirection; downloading of page assets; AJAX calls; etc) would still be outside of your control and are prohibited from customizing the Host header, leading the browser to fall back to standard DNS resolution.
Your only options are modifying the local DNS resolution (via /etc/hosts) or providing an alternative (via a proxy).

Make client.HTTPConnection connect to a specific IP address

Is there a way to force Python's client.HTTPConnection to connect to a specific IP address? I am writing a program that checks for the presence of a file on a web server, but I want to check every single web server, and the web servers use DNS round-robin. So I am using dns.resolver.query to get a list of all of the IP addresses associated with a specific IP address, and then I am using client.HTTPConnection to connect to each one. At least, that's what I want to do, but the client.HTTPConnection doesn't seem to.
Internally, client.HTTPConnection eventually calls socket.create_connection, but I've traced the code and can't figure out a good work-around.
I've tried URL's like http://2899902734:80/ for Google as well as http://172.217.1.14 and they don't work.

Categories

Resources