V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
推荐学习书目
Learn Python the Hard Way
Python Sites
PyPI - Python Package Index
http://diveintopython.org/toc/index.html
Pocoo
值得关注的项目
PyPy
Celery
Jinja2
Read the Docs
gevent
pyenv
virtualenv
Stackless Python
Beautiful Soup
结巴中文分词
Green Unicorn
Sentry
Shovel
Pyflakes
pytest
Python 编程
pep8 Checker
Styles
PEP 8
Google Python Style Guide
Code Style from The Hitchhiker's Guide
fate0
V2EX  ›  Python

写了个使用 Google Chrome Dev Protocol 来操作 chrome/headless chrome 的 Python Package

  •  
  •   fate0 ·
    fate0 · 2017-08-03 09:30:26 +08:00 · 6085 次点击
    这是一个创建于 2459 天前的主题,其中的信息可能已经有所发展或是发生改变。

    项目地址: fate0/pychrome

    用处:

    直接使用 Google Chrome Dev Protocol 操作 chrome/headless chrome,比较灵活(前提要过一遍 Protocol) 。 更多信息请看 README.md

    为什么要写:

    想使用 headless chrome 来替换 PhantomJS 作爬虫,我找了一下,Python 好像并没有和 chrome-remote-interface 一样直接使用 Chrome DevTools Protocol 来操作 chrome 的 Package,后面就自己写了一个。

    最后:

    欢迎各种 star、issue 以及 pr (。・`ω´・)

    12 条回复    2018-05-11 06:55:07 +08:00
    chengxiao
        1
    chengxiao  
       2017-08-03 10:06:38 +08:00
    和 selenium 的区别是???
    CryMeatel
        2
    CryMeatel  
       2017-08-03 10:10:04 +08:00
    赞~ 又见 fate 大神~
    jason0916
        3
    jason0916  
       2017-08-03 10:22:34 +08:00
    感觉有点意思,但是看了下代码,是不是支持的功能有点少?
    w0000
        4
    w0000  
       2017-08-03 10:22:56 +08:00
    @chengxiao selenium 在速度上还是慢了点
    fate0
        5
    fate0  
    OP
       2017-08-03 10:23:04 +08:00
    @chengxiao 区别是更接近 Dev Protocol 吧,selenium 依赖 ChromeDriver,然而 ChromeDriver 还是使用 Dev Protocol 来操作 chrome (这段话单讲 chrome...)
    fate0
        6
    fate0  
    OP
       2017-08-03 10:26:49 +08:00
    @jason0916 功能多不多,主要看 dev protocol 开放的接口多不多,chrome 61 之后多了个 Network.requestIntercepted,看到这个 method,我就觉得 headless chrome 能够写爬虫了。
    knightdf
        7
    knightdf  
       2017-08-03 10:32:24 +08:00
    我觉得单论爬虫 splash 比 selenium 好用点
    Fen2g
        8
    Fen2g  
       2017-08-03 10:35:58 +08:00
    已 star,公司已经有在用不过是 node。这个 python 希望楼主继续加油!
    scys
        9
    scys  
       2017-08-03 11:02:13 +08:00
    Stared :D
    挺好,近来研究自动化家庭框架。用得上。
    slideclick
        10
    slideclick  
       2017-08-03 11:31:07 +08:00
    看楼主破解了 ruby 的混乱工具,搭车问一下,python 有比较好的混乱工具么?
    fate0
        11
    fate0  
    OP
       2017-08-03 12:51:32 +08:00
    @slideclick 简单的方法就是转成 c 代码,需要保密的代码我直接用 go 写
    atsummer
        12
    atsummer  
       2018-05-11 06:55:07 +08:00
    好不容易找到的,已经 star,感谢楼主^_^
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   863 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 20:44 · PVG 04:44 · LAX 13:44 · JFK 16:44
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.