google chrome开发协议的python包
pychrome的Python项目详细描述
#pychrome
[![构建状态](https://travis-ci.org/fate0/pychrome.svg?branch=master)(https://travis ci.org/fate0/pychrome)
[![codecov](https://img.shields.io/codecov/c/github/fate0/pychrome.svg)(https://codecov.io/gh/fate0/pychrome)
[![更新](https://pyup.io/repos/github/fate0/pychrome/shield.svg)(https://pyup.io/repos/github/fate0/pychrome/)
[![pypi](https://img.shields.io/pypi/v/pychrome.svg)(https://pypi.python.org/pypi/pychrome)
[![pypi](https://img.shields.io/pypi/pyversions/pychrome.svg)(https://github.com/fate0/pychrome)
[更多文档](https://fate0.github.io/pychrome/pychrome/)
目录
>
*[安装]
*[安装Chrome](\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*[参考](参考)
安装pychrome,简单地说:
`````
>$pip install-u py chrome
``````
```````
>$pip install-u git+https://github.com/fate0/pychrome.git
`````
`````````>
```````
``````
`````````
只需:
```
$google chrome--远程调试端口=9222
````
或无头模式(Chrome版本>;=59):
`````
````
`>或者使用Docker:
```````````
````````````
``或者使用Docker的远程调试端口=9222
``````
````````
`````
`
```````````
`=
````````````>
``````````````````````` python
导入pychrome
#创建浏览器实例
browser=pychrome.browser(url=“http://127.0.0.1:9222”)
=请求将被发送到tab.start()
\start tab.start()
\call method
tab.network.enable()
\call method with timeout
tab.page.navigate(url=“https://github.com/fate0/pychrome”,_超时=5)
=pychrome.browser(url=“http://127.0.0.1:9222”)
tab=browser.new戋tab()
def request戋u will戋u be戋u sent(**kwargs):
print(“loading:%s%kwargs.get('request').get('url'))
tab.set戋listener(“network.requestwillbesent”,请求将被发送)
tab.start()
tab.call_method(“network.enable”)
tab.call_method(“page.navigate”,url=“https://github.com/fate0/pychrome”,_超时=5)
tab.wait(5)
tab.stop()
browser.close_au tab(tab)
`````
[Chrome devtools protocol](https://chromedevtools.github.io/devtools protocol/tot/)
debug
设置调试环境变量:
![pychrome_with_debug_env](https://raw.githubusercontent.com/fate0/pychrome/master/docs/images/pychrome_debug_env.png)
[pychrome_tab_management](https://raw.githubusercontent.com/fate0/pychrome/master/docs/images/pychrome_tab_management.png)
*[chrome远程接口](https://github.com/cyrus and/chrome remote interface/)
*[chrome devtools协议](https://chromedevtools.github.io/devtools-protocol/tot/)
[![构建状态](https://travis-ci.org/fate0/pychrome.svg?branch=master)(https://travis ci.org/fate0/pychrome)
[![codecov](https://img.shields.io/codecov/c/github/fate0/pychrome.svg)(https://codecov.io/gh/fate0/pychrome)
[![更新](https://pyup.io/repos/github/fate0/pychrome/shield.svg)(https://pyup.io/repos/github/fate0/pychrome/)
[![pypi](https://img.shields.io/pypi/v/pychrome.svg)(https://pypi.python.org/pypi/pychrome)
[![pypi](https://img.shields.io/pypi/pyversions/pychrome.svg)(https://github.com/fate0/pychrome)
[更多文档](https://fate0.github.io/pychrome/pychrome/)
目录
>
*[安装]
*[安装Chrome](\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*[参考](参考)
安装pychrome,简单地说:
`````
>$pip install-u py chrome
``````
```````
>$pip install-u git+https://github.com/fate0/pychrome.git
`````
`````````>
```````
``````
`````````
只需:
```
$google chrome--远程调试端口=9222
````
或无头模式(Chrome版本>;=59):
`````
````
`>或者使用Docker:
```````````
````````````
``或者使用Docker的远程调试端口=9222
``````
````````
`````
`
```````````
`=
````````````>
``````````````````````` python
导入pychrome
#创建浏览器实例
browser=pychrome.browser(url=“http://127.0.0.1:9222”)
=请求将被发送到tab.start()
\start tab.start()
\call method
tab.network.enable()
\call method with timeout
tab.page.navigate(url=“https://github.com/fate0/pychrome”,_超时=5)
=pychrome.browser(url=“http://127.0.0.1:9222”)
tab=browser.new戋tab()
def request戋u will戋u be戋u sent(**kwargs):
print(“loading:%s%kwargs.get('request').get('url'))
tab.set戋listener(“network.requestwillbesent”,请求将被发送)
tab.start()
tab.call_method(“network.enable”)
tab.call_method(“page.navigate”,url=“https://github.com/fate0/pychrome”,_超时=5)
tab.wait(5)
tab.stop()
browser.close_au tab(tab)
`````
[Chrome devtools protocol](https://chromedevtools.github.io/devtools protocol/tot/)
debug
设置调试环境变量:
![pychrome_with_debug_env](https://raw.githubusercontent.com/fate0/pychrome/master/docs/images/pychrome_debug_env.png)
[pychrome_tab_management](https://raw.githubusercontent.com/fate0/pychrome/master/docs/images/pychrome_tab_management.png)
*[chrome远程接口](https://github.com/cyrus and/chrome remote interface/)
*[chrome devtools协议](https://chromedevtools.github.io/devtools-protocol/tot/)