How to Use Mobile Proxies with Selenium

Chrome has no flag for proxy passwords, so plain Selenium cannot sign in to a proxy by itself. The selenium-wire package adds that for Python, and the code below passes your line and prints the address the IP page sees.

What do I need before I start?

Hostgw.mobileproxy.live
HTTP and HTTPS port9000
SOCKS5 port9100
Usernamemp4x9q2.mobile.us.sid-a1b2.rot-10
PasswordYOUR_PASSWORD (your own line password)
  • Python 3.9 or newer and Chrome
  • pip install selenium selenium-wire "blinker<1.8"
  • Your username and password in your account under My lines. The username above is an example, and each part is explained in the username reference.

How do I set it up?

  1. Install the packages with the pip command in the list above.
  2. Save the code below as check_ip.py.
  3. Replace YOUR_PASSWORD with your password.
  4. Run python check_ip.py. Chrome opens and the page text prints.
  5. Create one driver per account with its own proxy dictionary when you need separate addresses.
  6. Always call driver.quit() at the end so the browser closes.

What does the code look like?

check_ip.py
from seleniumwire import webdriver

proxy = "http://mp4x9q2.mobile.us.sid-a1b2.rot-10:YOUR_PASSWORD@gw.mobileproxy.live:9000"
options = {"proxy": {"http": proxy, "https": proxy, "no_proxy": "localhost,127.0.0.1"}}

driver = webdriver.Chrome(seleniumwire_options=options)
driver.get("https://ipinfo.io/json")
print(driver.find_element("tag name", "body").text)
driver.quit()

How do I check my IP?

The script prints the JSON of https://ipinfo.io/json. The ip and country must belong to your line.

https://ipinfo.io/json

On a mobile line you can ask for a fresh address at any time with your change-IP link, for example https://gw.mobileproxy.live/rotate/k7Qm2xV9. The real link for each line is in your account.

What if it does not work?

ModuleNotFoundError about blinker.

Install an older blinker with pip install "blinker<1.8", which the selenium-wire package expects.

Certificate warnings appear.

selenium-wire inspects traffic through its own certificate. Use it only for your own work, and see its documentation for the options.

Chrome opens without the proxy.

Make sure you imported webdriver from seleniumwire, and not from selenium.

Frequently asked questions

Is there a way without selenium-wire?

You can load a small browser extension that fills in the proxy login, but selenium-wire is the shortest route and needs no extra files.

Does it work with Firefox?

Yes. Import the Firefox driver from seleniumwire and pass the same options.

How do I hold one IP across a test?

Use a sticky session id in the username, and keep the test shorter than the rotation timer.

Related guides

Need a line to connect?

Create an account, top up your balance and your first line is ready to use with Selenium.

Create account