Is it possible to switch to a new profile without opening a new window?
def proxyfunc(proxydir):
print 'Starting proxy...'
print proxydir
proxyamount = sum(1 for line in open(proxydir))
print proxyamount
proxynum = 0
with open(proxydir, "r") as proxy_text_file:
for line in itertools.islice(proxy_text_file, proxynum, (proxynum + 1)):
b = line.split(":")
print b
print 'making 2 variables'
proxyip, tempproxyport = b
print proxyip
print tempproxyport
proxyport = (tempproxyport.strip('n'))
print proxyport
if(proxynum >= proxyamount):
proxynum = 0
else:
proxynum = proxynum + 1
proxyprofile = webdriver.FirefoxProfile()
proxyprofile.set_preference("network.proxy.type", 1)
proxyprofile.set_preference("network.proxy.http", proxyip)
proxyprofile.set_preference("network.proxy.http_port", proxyport)
proxyprofile.update_preferences()
driver = webdriver.Firefox(firefox_profile=proxyprofile)
As seen in the code above I would like to switch to a proxy and then the new profile with a proxy but when I do so it opens a new window.
Sorry for the messy code and I know its probably not efficient but I'm new to python coming from C.
Aucun commentaire:
Enregistrer un commentaire