与硒一起使用代理旋转-python

时间:2020-05-30 22:09:23

标签: python selenium selenium-chromedriver

所以我试图用https://www.proxyrotator.com/连接我的程序,该程序返回一个随机代理。我已经检查了我的代码,代理正在输出为ip:port。这是我当前的代码,只需返回连接了代理的chrome_options

def getProxy(self):
    url = 'http://falcon.proxyrotator.com:51337/'
    params = dict(
        apiKey=self.api
    )

    resp = requests.get(url=url, params=params)
    data = json.loads(resp.text)
    proxy = data.get('proxy')

    chrome_options = webdriver.ChromeOptions()
    chrome_options.add_argument('--proxy-server=https://%s' % proxy)

    return chrome_options;

出于某种原因,Chrome无法连接。我做错了什么。谢谢。

0 个答案:

没有答案