推荐学习书目
› 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
yangzhezjgs
V2EX  ›  Python

requests 的作者的新项目 requests-html

  •  1
     
  •   yangzhezjgs · Feb 28, 2018 · 12982 views
    This topic created in 3178 days ago, the information mentioned may be changed or developed.
    https://github.com/kennethreitz/requests-html

    This library intends to make parsing HTML (e.g. scraping the web) as simple and intuitive as possible.

    When using this library you automatically get:

    -Full JavaScript support!
    -CSS Selectors (a.k.a jQuery-style, thanks to PyQuery).
    -XPath Selectors, for the faint at heart.
    -Mocked user-agent (like a real web browser).
    -Automatic following of redirects.
    -Connection – pooling and cookie persistence.
    -The Requests experience you know and love, with magical parsing abilities.

    对 requests 做了封装,添加了解析 html 的接口,总代码现在是 399 行,还在更新
    Supplement 1  ·  Feb 28, 2018
    目前版本还不稳定,作者应该还在修改更新中,出现问题请稍安勿躁
    现在代码新增为 484 行(昨天我刚看到的时候是 200 多行)
    44 replies  •  2018-05-27 21:31:45 +08:00
    mYYnSmiTEQWcCwAr
    mYYnSmiTEQWcCwAr
    Feb 28, 2018 via Android
    1
    mark 先 star 为敬
    lhx2008
    lhx2008
    Feb 28, 2018 via Android
    2
    把 pyquery 和 xpath 弄进来了,还有自动 useragent,是要一统江湖的节奏
    co3site
    co3site
    Feb 28, 2018 via Android
    3
    观望中,先 star
    Sanko
    Sanko
    Feb 28, 2018 via Android
    4
    orz
    prolic
    prolic
    Feb 28, 2018
    5
    star 为敬,beautifulsoup 用着还是不够爽
    weiwio
    weiwio
    Feb 28, 2018 via Android
    6
    今天看了一下,原来是新项目,很有希望啊
    fyyz
    fyyz
    Feb 28, 2018
    7
    吊炸天
    tuding
    tuding
    Feb 28, 2018
    8
    这个作者好腻害,好多牛逼项目
    steveway
    steveway
    Feb 28, 2018 via Android
    9
    看作者就 star 系列
    lfzyx
    lfzyx
    Feb 28, 2018
    10
    可以放弃 bs4 了?
    CSM
    CSM
    Feb 28, 2018
    11
    期待有人封装 aiohttp
    sunwei0325
    sunwei0325
    Feb 28, 2018
    12
    如果下载和解析分开异步进行就好了
    angelshq
    angelshq
    Feb 28, 2018
    13
    mark
    Zzde
    Zzde
    Feb 28, 2018 via iPhone
    14
    Mark
    find456789
    find456789
    Feb 28, 2018
    15
    不太明白,这个 库 用来替代谁的?
    find456789
    find456789
    Feb 28, 2018
    16
    请问这个库 是 requests+bs4 吗
    douglarek
    douglarek
    Feb 28, 2018❤️1
    17
    xxx for humans 又来了?没有 xxx 之前莫不是大家都在吃猪食 ?
    soulmine
    soulmine
    Feb 28, 2018
    18
    @find456789 大约看了下 大概类似于 requests+bs4+selenium/phantomjs 不过后面两个现在只是封装了一小部分功能 比如通过 css selector 解析或者执行 js 代码这种
    soulmine
    soulmine
    Feb 28, 2018
    19
    @sunwei0325 你可以自己异步啊 比如用队列什么的
    hugo2lee
    hugo2lee
    Feb 28, 2018
    20
    Only later versions of Python 3 are supported. 好评
    zhoulv2012
    zhoulv2012
    Feb 28, 2018
    21
    都是实用的功能啊!
    knightdf
    knightdf
    Feb 28, 2018
    22
    还可以解析 JS ?怎么感觉是个爬虫库了
    dqh3000
    dqh3000
    Feb 28, 2018
    23
    哎呀呀呀呀?

    不错不错……这个好
    ioven
    ioven
    Feb 28, 2018
    24
    https://github.com/scrapy/parsel 一直用的这货,re css xpath 用起来很爽
    Mavious
    Mavious
    Feb 28, 2018
    25
    非程序猿表示非常感兴趣。requests 太好用了,太是适合我等毫无基础的小白了,轻松上手。
    sowish
    sowish
    Feb 28, 2018
    26
    看了下,安装 requests-html 同时需要 bs4,lxml 等库,估计还是依赖于这些库
    4BVL25L90W260T9U
    4BVL25L90W260T9U
    Feb 28, 2018 via Android
    27
    恕我直言,没看懂这个库存在的意义,lxml 足够好用了,重点是 xpath 这种东西应该存在配置里,而不是把解析逻辑写在代码里
    wfd0807
    wfd0807
    Feb 28, 2018
    28
    Full JavaScript Support by Chromium headless mode.
    wfd0807
    wfd0807
    Feb 28, 2018❤️1
    29
    the first time you ever run the render() method, it will download Chromium ...
    yech1990
    yech1990
    Feb 28, 2018
    30
    399 行代码已经 4600 stars 了。

    ---

    另外作者现在摄影技术也逆天。
    yech1990
    yech1990
    Feb 28, 2018
    31
    看依赖需要 bs4
    但代码中又没有出现?
    yangzhezjgs
    yangzhezjgs
    OP
    Feb 28, 2018
    32
    @yech1990 这个应该是之前用了 bs4,后来又改用其他的,但是依赖里面没有去掉,因为昨天我看的时候代码才 200 行
    wellsc
    wellsc
    Feb 28, 2018 via iPad
    33
    像是拯救世界
    tcpdump
    tcpdump
    Feb 28, 2018
    34
    文档好多错误,跑不起来
    VicYu
    VicYu
    Feb 28, 2018
    35
    for the horde
    abmin521
    abmin521
    Feb 28, 2018 via Android
    36
    顶 k 神下
    Ginson
    Ginson
    Feb 28, 2018
    37
    研究中。文档确实错误挺多
    Tutorial 第一行代码 from requests_html import HTMLSession 就报错,应该 import Session
    LINAICAI
    LINAICAI
    Feb 28, 2018 via iPhone
    38
    明显是爬虫嘛……
    WildCat
    WildCat
    Feb 28, 2018
    39
    感谢作者,正需求这样的库!



    @Ginson
    import HTMLSession 报错的原因是因为它会自动加载 fake_useragents.json,你的网络可能不能访问 cloudfront。
    认真读一秒报错提示吧。
    Ginson
    Ginson
    Feb 28, 2018
    40
    @WildCat 谢谢,我还在研究。不过报错提示我实在没看出啥…
    WildCat
    WildCat
    Feb 28, 2018
    41
    @Ginson 你这个应该也是同样的问题我觉得。。。
    换 jupyter lab/notebook 吧,命令行 IPython 还是有点不好用。
    jimmyye
    jimmyye
    Feb 28, 2018
    42
    版本更新太快,所以用的时候要注意安装的版本和 Github 上的代码 commit 时间。
    pdog18
    pdog18
    Apr 16, 2018
    43
    我想问下这个库可以将<script>标签里面的 js 代码快速转换成 python 对象吗?有什么办法吗?正好遇到这个问题。
    现在只能换成字符串强行切
    windcode
    windcode
    May 27, 2018
    44
    目前已经 700 行代码,7700+ star,有没有人用过,感觉如何?
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   4637 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 124ms · UTC 01:32 · PVG 09:32 · LAX 17:32 · JFK 20:32
    ♥ Do have faith in what you're doing.