python pyquery 学习手册
安装与使用
pyquery: 一个为 python 定制的 jquery-like 库
简介 pyquery: a jquery-like library for python
pyquery allows you to make jquery queries on xml documents. The API is as much as possible the similar to jquery. pyquery uses lxml for fast xml and html manipulation.
安装
pip install requests
pypi源速度过慢的情况下,可以考虑切换至国内源百度一下解决方案
例子:使用清华源
sudo -H pip install requests -i https://pypi.tuna.tsinghua.edu.cn/simple/ –trusted-host pypi.tuna.tsinghua.edu.cn
QuickStart
12345678910111213
# 定义一段 htmlhtml = """<html><head><title>The Dormouse's story</title></head><body><p class="title" name="dromouse"><b>The Dormouse's story</b></p><p class="story">Once upon a time there were three little sisters; and their names were<a href="http://example.com/elsie" class="sister" id="link1"><!-- Elsie --></a>,<a href="http://example.com/lacie" class="sister" id="link2">Lacie</a> and<a href="http://example.com/tillie" class="sister" id="link3">Tillie</a>;and they lived at the bottom of a well.</p><p class="story">...</p></body><html>"""
|
|
获取属性
|
|
操作CSS
|
|