from selenium import webdriver
proxy = "166.88.124.111"
port = "3111"
profile = webdriver.FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", proxy)
profile.set_preference("network.proxy.http_port", port)
profile.set_preference("network.proxy.ssl", proxy)
profile.set_preference("network.proxy.ssl_port", port)
profile.update_preferences()
driver = webdriver.Firefox(executable_path="C:\Program Files\Mozilla Firefox\geckodriver.exe", firefox_profile=profile)
driver.get("https://www.iplocation.net/find-ip-address")
Now that i think about it why not just make firefox use a specific port and use a program to host the proxy through that port? Most of the proxy switchers/checkers can host themI tried a few scripts from stackoverflow and they don't work..
My proxies have no username and password btw.
I'm using the latest version of Python, FireFox and Selenium.
Maybe try it like this: https://stackoverflow.com/q/17082425/4964331. I'd suggested this to a friend earlier it worked for him.
Also, just a heads up. https://whatismyip.com and perhaps https://www.iplocation.net/find-ip-address as well do frontend check using Javascript. So it can know your real IP even when you use the most opaque proxies.
To avoid frontend detection, either disable javascript or use a VPN instead.
To only check whether Firefox is using the proxies, use https://icanhazip.com.
profile = FirefoxProfile()
profile.set_preference("network.proxy.type", 1)
profile.set_preference("network.proxy.http", proxyip)
profile.set_preference("network.proxy.http_port", proxyport)
profile.set_preference("network.proxy.ssl", proxyip)
profile.set_preference("network.proxy.ssl_port", proxyport)
driver= webdriver.Firefox(profile)
This block of code works fine, but port field has to be numeric:This is my script..
It gives no errors but leaks my IP...
Code:from selenium import webdriver proxy = "166.88.124.111" port = "3111" profile = webdriver.FirefoxProfile() profile.set_preference("network.proxy.type", 1) profile.set_preference("network.proxy.http", proxy) profile.set_preference("network.proxy.http_port", port) profile.set_preference("network.proxy.ssl", proxy) profile.set_preference("network.proxy.ssl_port", port) profile.update_preferences() driver = webdriver.Firefox(executable_path="C:\Program Files\Mozilla Firefox\geckodriver.exe", firefox_profile=profile) driver.get("https://www.iplocation.net/find-ip-address")
I'm using the latest version of FF, Python and Selenium.
Edit: it's updating the proxy in FF options but the port field is blank. If I manually enter the port the proxy works.
###############################################################################
# MIPYTHON .com PYTHON PROXY SCRAPE and GO SCRIPT in SELENIUM
###############################################################################
from selenium import webdriver
import time
print("*" * 60)
print("MIPYTHON .com PYTHON PROXY SCRAPE and GO SCRIPT in SELENIUM")
print("*" * 60)
browser = webdriver.Firefox()
proxy_website = "https://free-proxy-list.net/"
target_website = "https://www.whatismyip.com"
### SCRAPE PROXY
browser.get(proxy_website)
browser.find_element_by_xpath('/html/body/header/div[1]/div/div[1]/div/div/a[2]').click()
proxy = browser.find_element_by_xpath('/html/body/section[1]/div/div[2]/div/div[2]/div/table/tbody/tr[1]/td[1]').text
print(proxy)
proxy_port = browser.find_element_by_xpath('/html/body/section[1]/div/div[2]/div/div[2]/div/table/tbody/tr[1]/td[2]').text
print(proxy_port)
### USE PROXY
#proxy = "89.23.19.143"
#proxy_port = 8080
#proxy = int(proxy)
#proxy_port = int(proxy_port)
#proxy = str(proxy)
#proxy_port = str(proxy_port)
proxy_profile = webdriver.FirefoxProfile()
proxy_profile.set_preference("network.proxy.type", 1)
proxy_profile.set_preference("network.proxy.http", proxy )
proxy_profile.set_preference("network.proxy.http_port", proxy_port)
proxy_profile.set_preference("network.proxy.ssl", proxy )
proxy_profile.set_preference("network.proxy.ssl_port", proxy_port)
browser = webdriver.Firefox(firefox_profile=proxy_profile)
target_website = browser.get(target_website)
proxy_port = int(proxy_port)
proxy = str(proxy)
This block of code works fine, but port field has to be numeric:
port = int("3111")
Because of that you are getting that field blank.
@MAG WEB DESIGNS
Hey MAG, i been working on selenium for while now, using Firefox and Selenium + gecko driver . i dont know if you know but we can use gecko driver to access anything except google. i try proxies to access google with gecko Firefox and always come to capcha site. If I just fire up pure Firefox without gecko and manual change the proxies then there will be no capcha. Lead me to wonder if there is a way to go thru Firefox without gecko or another browser. have you experiences this issue ? Thanks
Im not sure on phantomJS part but ill look into headless firefox. I use Gimmeproxy subcription, they are public proxies btw, it weird since the same proxy with gecko would get caught and not caught if manually input into firefox.My Bad sxiclub already answered this....
Don't access Google with dirty proxies all free proxies are dirty. Try headless with phantom JS though support is discontinued?
how about give int value in port like "int(port)"This is my script..
It gives no errors but leaks my IP...
Code:xxxxxxx
I'm using the latest version of FF, Python and Selenium.
Edit: it's updating the proxy in FF options but the port field is blank. If I manually enter the port the proxy works.