__init__.py 文件源码

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

项目:ChromeHeadlessInterface 作者: wilson9x1 项目源码 文件源码
def _open_new_tab(self):
        url = ChromeAPI.OPEN_NEW_TAB_URL.format(self._host, self._port)
        try:
            response = requests.get(url)
        except Exception as e:
            print("Error while access {0}, please check chrome browser.".format(url))
            print("Details error: {0}".format(e))
            return False
        response = response.json()
        tab_id = response.get("id")
        if not tab_id:
            return False
        ws_url = response.get("webSocketDebuggerUrl")
        if not ws_url:
            return False

        ws_instance = websocket.create_connection(ws_url, timeout=self._timeout)
        if not ws_instance:
            return False

        self._tab = {
            "tab_id": tab_id,
            "ws_url": ws_url,
            "ws_instance": ws_instance
        }
        return self._tab
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号