Python中的Xpath

import requests
hd = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.140 Safari/537.36 Edge/17.17134"}
a=requests.get("http://www.hljswkj.org.cn/",headers = hd)
b=a.content.decode('utf-8')
from lxml import etree
d = etree.HTML(b)
c = d.xpath("//ul[@class='tzgg']//li/div/a/text()")
print(c)
上一篇:Python数据分析


下一篇:Python(IT峰)笔记14-爬虫实战、认识爬虫,安装request库,发送get请求,请求头,post请求,cookie,session,xpath,xpath解析html,xpath常用规则