selenium.py 文件源码

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

项目:SerpScrap 作者: ecoron 项目源码 文件源码
def _get_Chrome(self):
        try:
            chrome_ops = webdriver.ChromeOptions()
            if self.proxy:
                chrome_ops = webdriver.ChromeOptions()
                chrome_ops.add_argument(
                    '--proxy-server={}://{}:{}'.format(
                        self.proxy.proto,
                        self.proxy.host,
                        self.proxy.port
                    )
                )
                self.webdriver = webdriver.Chrome(
                    executable_path=self.config['executable_path'],
                    chrome_options=chrome_ops
                )

            chrome_ops.add_argument('--no-sandbox')
            chrome_ops.add_argument('--start-maximized')
            chrome_ops.add_argument(
                '--window-position={},{}'.format(
                    randint(10, 30),
                    randint(10, 30)
                )
            )
            chrome_ops.add_argument(
                '--window-size={},{}'.format(
                    randint(800, 1024),
                    randint(600, 900)
                )
            )
            self.webdriver = webdriver.Chrome(
                executable_path=self.config['executable_path'],
                chrome_options=chrome_ops
            )
            return True
        except WebDriverException:
            raise
        return False
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号