与google chrome远程shell端口对话的客户端
chrome_remote_shell的Python项目详细描述
警告
远程调试程序已被删除 从谷歌Chrome的最新版本来看, 因此,这个python模块只具有历史意义。 有关浏览器新协议的更多信息, 访问:
https://developers.google.com/chrome-developer-tools/docs/remote-debugging
这个库使与google chrome远程通信变得容易 从python调试shell。要使外壳可用,请启动chrome 使用此选项:
google-chrome --remote-shell-port=9222
然后您可以通过如下代码从python连接:
>>> import chrome_remote_shell >>> shell = chrome_remote_shell.open(port=9222) >>> shell.request('DevToolsService', command='ping') {u'data': u'ok', u'command': u'ping', u'result': 0}
协议的详细说明见:
http://code.google.com/p/chromedevtools/wiki/ChromeDevToolsProtocol
为了方便起见,shell连接对象提供了一个方法,通过 将javascript注入第一个选项卡,命令chrome打开一个url 在新选项卡中:
shell.open_url('http://www.aldaily.com/')
更改日志
2009年2月26日。添加了条件导入 模块在Python2.5下运行。