Jump to content
  • 0

Selenium python proxy


BeHappy4Ever

Question

2 answers to this question

Recommended Posts

  • 0

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 post
  • 0
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 post

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • 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.