def getFirefoxBrowser():
proxy = {'host': "proxy.abuyun.com", 'port': 9020, 'usr': "HWJB1R49VGL78Q3D", 'pwd': "0C29FFF1CB8308C4"}
# userProfileFilePath = r"C:\Users\LZ\AppData\Roaming\Mozilla\Firefox\Profiles\vbqy66hj.default"
# kadUserProfileFilePath = r"C:\Users\zml\AppData\Roaming\Mozilla\Firefox\Profiles\lotur5zd.default"
fp = webdriver.FirefoxProfile(localData.FirefoxUserProfileFilePath)
fp.add_extension('resource/closeproxy.xpi')
fp.set_preference('network.proxy.type', 1)
fp.set_preference('network.proxy.http', proxy['host'])
fp.set_preference('network.proxy.http_port', int(proxy['port']))
fp.set_preference('network.proxy.ssl', proxy['host'])
fp.set_preference('network.proxy.ssl_port', int(proxy['port']))
fp.set_preference('network.proxy.ftp', proxy['host'])
fp.set_preference('network.proxy.ftp_port', int(proxy['port']))
fp.set_preference('network.proxy.no_proxies_on', 'localhost, 127.0.0.1')
# ???????????
fp.set_preference('permissions.default.image', 2)
credentials = '{usr}:{pwd}'.format(**proxy)
credentials = b64encode(credentials.encode('ascii')).decode('utf-8')
fp.set_preference('extensions.closeproxyauth.authtoken', credentials)
browser = webdriver.Firefox(executable_path="resource/geckodriver", firefox_profile=fp)
# browser = webdriver.Firefox(executable_path="geckodriver")
browser.set_page_load_timeout(1)
return browser
评论列表
文章目录