Answer the question
In order to leave comments, you need to log in
How to download file from proxy in chrome webdriver?
Guys please help. I need proxies to be opened from a .txt file, one proxy:port per line, next. line one more proxy:port and so on in the list. Need to open randomly. I'm trying to write through a file, logically it should work, in fact - after opening Google Chrome writes "connection error - check proxy", Pycharm does not give an error. I have been studying python recently, explain, as a teapot, what exactly is wrong and why. Thanks
from selenium import webdriver
proxy_list = []
f = open ('/home/user/download/proxy.txt', 'r')
for line in f:
line.replace('/n', "")
proxy_list.append(line)
f.close()
PROXY = random.choice('proxy_list')
ch_options = webdriver.ChromeOptions()
ch_options.add_argument('--proxy-server=%s'%PROXY)
driver = webdriver.Chrome(options=ch_options)
driver.get('https://duckduckgo.com/')
Answer the question
In order to leave comments, you need to log in
Remove the single quotes in the string, otherwise a random letter from the string
'proxy_list' is entered into PROXY. PROXY = random.choice('proxy_list')
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question