Python 的 HTML 解析库 Requests-HTML

码农软件 · 软件分类 · 网络工具包 · 2019-02-23 01:01:00

软件介绍

Requests-HTML 对 PyQuery、requests、lxml 等库。

requests-html 具有以下特性

  • 完全支持 JavaScript

  • CSS 选择器

  • XPath 选择器

  • 模拟用户代理(如同真正的网络浏览器)

  • 自动跟踪重定向

  • 连接池和 cookie 持久化

安装

pip install requests-html

使用方法

>>> from requests_html import session

# 返回一个Response对象
>>> r = session.get('https://python.org/')

# 获取所有链接
>>> r.html.links
{'/users/membership/', '/about/gettingstarted/'}

# 使用css选择器的方式获取某个元素
>>> about = r.html.find('#about')[0]

>>> print(about.text)
About
Applications
Quotes
Getting Started
Help
Python Brochure

还有一个非常吸引人的特点是,它能将 HTML 转换为 Markdown 文本

# 将html转换为Markdown文本
>>> print(about.markdown)

* [About](/about/)

  * [Applications](/about/apps/)
  * [Quotes](/about/quotes/)
  * [Getting Started](/about/gettingstarted/)
  * [Help](/about/help/)
  * [Python Brochure](http://brochure.getpython.info/)

本文地址:https://codercto.com/soft/d/3.html

TED Talks Storytelling: 23 Storytelling Techniques from the Best

TED Talks Storytelling: 23 Storytelling Techniques from the Best

Akash Karia / CreateSpace Independent Publishing Platform / 2015-1-11 / USD 6.99

"Every speaker can put these ideas into practice immediately -- and they should!" ~ Dr. Richard C. Harris, Certified World Class Speaking Coach "An insightful read" ~Dennis Waller, Top 500 Revie......一起来看看 《TED Talks Storytelling: 23 Storytelling Techniques from the Best》 这本书的介绍吧!

CSS 压缩/解压工具
CSS 压缩/解压工具

在线压缩/解压 CSS 代码

HTML 编码/解码
HTML 编码/解码

HTML 编码/解码