pyquery的使用
常用的三种初始化方法:
1.字符串初始化:
from pyquery import PyQuery as pq html=""" <html> <head> <title>测试pyquery </title> </head> </html> """ doc = pq(html) print("title")
2.url初始化
1 from pyquery import PyQuery as pq 2 3 4 doc = pq(url="www.baidu.com") 5 print(doc("title"))
3.文件初始化
1 from pyquery import PyQuery as pq 2 3 4 doc=pq(filename="/home/index.html") 5 print(doc("title"))
基本CSS选择器