Jump to content

Selenium python proxy


Recommended Posts

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

So, I'm guessing you just need a simple bot to do some action with I assume seleium.webdriver through a proxy server, here's a simple example, all you gotta do is add to chromeOptions, the proxy address, ip_address:port, here's some code:

 

Prerequisites:

Keep in mind that the chromeDriver version has to be the same with ur chrome browser version, that is if you want to use chrome as ur browser.

 

 

from selenium import webdriver
from selenium.webdriver.common.by import By

chromeOptionsInstance = webdriver.ChromeOptions()

#Add ur proxy server id, port by
#Replace the string "YOUR_Ip_Address_Here" with ur proxyServer ip address between quotes like '127.0.0.1' in the below dictionary
#Replace the string "Your_Port_here" with ur proxy server port in the below dictionary
proxyServer = {'ip_Address':'YOUR_Ip_Address_Here',
               'port':'Your_Port_here'}

chromeOptionsInstance.add_argument(f'--proxy-server={proxyServer["ip_Address"]}:{proxyServer["port"]}')

#Create webdriver.Chrome instance, don't forget to add the absolute path to chromedriver.exe for this example
driver = webdriver.Chrome(executable_path=r"Ur_ChromeDriver_Absolute_Path\chromedriver.exe", chrome_options=chromeOptionsInstance)
driver.get('https://metin2.dev/board/topic/25185-selenium-python-proxy/#comment-134552')

#Click on Answer this question elem.
driver.find_element_by_xpath("//a[contains(text(),'Answer this question')]").click()

 

In regards of a discrete proxy server, I don't got any, but I suggest using an VPN, does the job, there are alot of these for free on the internet

Edited by MGA
Updated a missing request in the post with an answer
Link to comment
Share on other sites

10 hours ago, MGA said:

So, I'm guessing you just need a simple bot to do some action with I assume seleium.webdriver through a proxy server, here's a simple example, all you gotta do is add to chromeOptions, the proxy address, ip_address:port, here's some code:

 

Prerequisites:

Keep in mind that the chromeDriver version has to be the same with ur chrome browser version, that is if you want to use chrome as ur browser.

 

 


from selenium import webdriver
from selenium.webdriver.common.by import By

chromeOptionsInstance = webdriver.ChromeOptions()

#Add ur proxy server id, port by
#Replace the string "YOUR_Ip_Address_Here" with ur proxyServer ip address between quotes like '127.0.0.1' in the below dictionary
#Replace the string "Your_Port_here" with ur proxy server port in the below dictionary
proxyServer = {'ip_Address':'YOUR_Ip_Address_Here',
               'port':'Your_Port_here'}

chromeOptionsInstance.add_argument(f'--proxy-server={proxyServer["ip_Address"]}:{proxyServer["port"]}')

#Create webdriver.Chrome instance, don't forget to add the absolute path to chromedriver.exe for this example
driver = webdriver.Chrome(executable_path=r"Ur_ChromeDriver_Absolute_Path\chromedriver.exe", chrome_options=chromeOptionsInstance)
driver.get('https://metin2.dev/board/topic/25185-selenium-python-proxy/#comment-134552')

#Click on Answer this question elem.
driver.find_element_by_xpath("//a[contains(text(),'Answer this question')]").click()

 

In regards of a discrete proxy server, I don't got any, but I suggest using an VPN, does the job, there are alot of these for free on the internet

Thanks a lot brother for your answer.Wish you the best :)

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.