phantomjs.py 文件源码

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

项目:trackship 作者: nabeelio 项目源码 文件源码
def __init__(self, user_agent=None, cookies_file=None):
        """
        Initialize the phantom JS selenium driver
        :return:
        """
        self.conf = config
        self.user_agent = user_agent
        self.cookies_file = cookies_file

        # http://phantomjs.org/api/webpage/property/settings.html
        dcap = dict(DesiredCapabilities.PHANTOMJS)
        dcap['phantomjs.page.settings.loadImages'] = False
        dcap['phantomjs.page.settings.webSecurityEnabled'] = False
        dcap['phantomjs.page.settings.localToRemoteUrlAccessEnabled'] = True

        if user_agent:
            dcap['phantomjs.page.settings.userAgent'] = user_agent

        self.driver = webdriver.PhantomJS(
            desired_capabilities=dcap,
            executable_path=self.conf['general']['phantomjs'],
        )

        self.load_cookies()

        self.driver.implicitly_wait(30)
        self.driver.set_window_size(1024, 768)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号