seleniumDriver.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:pycrawler 作者: zyq001 项目源码 文件源码
def reflashProxy(caps, driver, pIPs):
    if len(pIPs) < minPIPCount:
        # ??ip???????
        pIPs = getAvailableIPs()
    # pipObj = random.choice(pIPs)
    randomPIpIndex = random.randint(0, len(pIPs))
    pipObj = pIPs[randomPIpIndex]
    pIp = pipObj[0]
    pPort = pipObj[1]
    ua = random.choice(USER_AGENTS)
    caps["phantomjs.page.settings.userAgent"] = ua
    proxy = webdriver.Proxy()
    proxy.proxy_type = ProxyType.MANUAL
    proxy.http_proxy = pIp + ':' + str(pPort)
    # ????????webdriver.DesiredCapabilities.PHANTOMJS?
    proxy.add_to_capabilities(caps)
    driver.start_session(caps)
    return pIPs, pIp, randomPIpIndex
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号