python-requests-html
# 1. 安装
pip install requests-html
# 2. 使用Requests向python.org发出 GET 请求:
from requests_html import HTMLSession
session = HTMLSession()
r = session.get('https://python.org/')
# 3. 使用
about=r.html.find('.nav_list',first=True) # Element使用 CSS 选择器选择一个
print(about.text) # 抓取 anElement的文本内容
print(about.attrs) # anElement的属性
print(about.html) # 渲染一个Element的 HTML:
print(about.find(".this")) # 在 中选择一个Element列表Element
print(about.absolute_links) # 搜索元素内的链接
print(r.html.search('拆单{}情')[0])# 在页面上搜索文本,固定格式
```

浙公网安备 33010602011771号