Python (Selenium) + Rotating Proxies

Hi! Ive been trying to use residential proxies from apify using python + selenium but when I tried to implement it on my apify and tried to open a website, it always says error does any of you have like a starting template to use selenium with rotating proxies? already read documentation and everything but still didnt work :/ (Im using it locally without actor, just plain simple python)
3 Replies
xenial-black
xenial-black14mo ago
Hi, I can help you. Please DM me
foreign-sapphire
foreign-sapphireOP14mo ago
found out how!

from seleniumwire import webdriver
import asyncio

async def main():
options = {
'proxy': {
'http': 'http://username:password@host:port', # Replace with your proxy URL
'https': 'http://username:password@host:port'
}
}

driver = webdriver.Chrome(seleniumwire_options=options)

for _ in range(10):
driver.get('https://api.apify.com/v2/browser-info')
print(driver.page_source)

driver.quit()

if __name__ == '__main__':
asyncio.run(main())

from seleniumwire import webdriver
import asyncio

async def main():
options = {
'proxy': {
'http': 'http://username:password@host:port', # Replace with your proxy URL
'https': 'http://username:password@host:port'
}
}

driver = webdriver.Chrome(seleniumwire_options=options)

for _ in range(10):
driver.get('https://api.apify.com/v2/browser-info')
print(driver.page_source)

driver.quit()

if __name__ == '__main__':
asyncio.run(main())
hope this help somebody
other-emerald
other-emerald14mo ago
I can help you

Did you find this page helpful?