使用xpath获取网页内容
安装 lxml
库
pip install lxml
示例
from lxml import etree
url = f""
respon = requests.get(url=url, verify=False).content.decode()
html = etree.HTML(respon)
urls = html.xpath('//*[@id="main-container"]/div[2]/div[1]/ul/li/a/@href')
2024-07-13 21:15:30
安装 lxml
库
pip install lxml
示例
from lxml import etree
url = f""
respon = requests.get(url=url, verify=False).content.decode()
html = etree.HTML(respon)
urls = html.xpath('//*[@id="main-container"]/div[2]/div[1]/ul/li/a/@href')