Robot.py 文件源码

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

项目:AmazonRobot 作者: WuLC 项目源码 文件源码
def __init__(self, proxy):
        """init the webdriver by setting the proxy and user-agent

        Args:
            proxy (str): proxy in the form of ip:port
        """
        # set proxy
        ip, port = proxy.split(':')
        profile = webdriver.FirefoxProfile()
        profile.set_preference("network.proxy.type", 1)
        profile.set_preference("network.proxy.http", ip)
        profile.set_preference("network.proxy.http_port", port)
        # set user_agent
        profile.set_preference("general.useragent.override", generate_user_agent())

        profile.update_preferences()
        self.driver = webdriver.Firefox(firefox_profile=profile)

        print 'current proxy: %s'%proxy
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号