library.py 文件源码

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

项目:chrome_remote_interface_python 作者: wasiher 项目源码 文件源码
def __init__(self, host, port, tabs=None, tab_id=None):
        super().__init__(host, port)
        self._host = host
        self._port = port
        if tab_id is None:
            tab_info = json.loads(call_method(self._host, self._port, 'new'))
            self._id = tab_info['id']
            self._ws_url = tab_info['webSocketDebuggerUrl']
        else:
            try:
                tab_info = None
                for current_tab_info in json.loads(call_method(self._host, self._port, 'list')):
                    if current_tab_info['id'] == tab_id:
                        tab_info = current_tab_info
                if tab_info is None:
                    raise ValueError('Tab {0} not found'.format(tab_id))
                self._id = tab_info['id']
                self._ws_url = tab_info['webSocketDebuggerUrl']
            except:
                self._id = tab_id
                self._ws_url = 'ws://{0}:{1}/devtools/page/{2}'.format(self._host, self._port, tab_id)
        self._soc = websocket.create_connection(self._ws_url)
        self._i = 0
        self._tabs = tabs
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号