adverse-sapphire
adverse-sapphire2y ago

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
stormy-gold
stormy-gold2y ago
Hi, I can help you. Please DM me
adverse-sapphire
adverse-sapphireOP2y 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
fascinating-indigo
fascinating-indigo2y ago
I can help you

Did you find this page helpful?