阅读背景:

selenium使用代理爬取数据

来源:互联网 
代理

因为chrome的代理使用目前还有一些问题,所以本文全部用的Firefox

http协议 host = "127.0.0.1" port = 9999 profile = webdriver.FirefoxOptions() profile.set_preference('network.proxy.type', 1) profile.set_preference('network.proxy.http', host) # IP为你的代理服务器地址:如‘127.0.0.0’,字符串类型 profile.set_preference('network.proxy.http_port', port) # PORT为代理服务器端口号:如,9999,整数类型 browser = webdriver.Firefox(options=profile) https协议 host = "127.0.0.1" port = 9999 profile = webdriver.FirefoxProfile() profile.set_preference('network.proxy.type', 1) profile.set_preference('network.proxy.http', "%s" % host) profile.set_preference('network.proxy.http_port', port) profile.set_preference('network.proxy.ssl', "%s" % host) profile.set_preference('network.proxy.ssl_port', port) profile.update_preferences() browser = webdriver.Firefox(firefox_profile=profile) 拨号上网 http协议 h



你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: