zl程序教程

您现在的位置是:首页 >  后端

当前栏目

python爬虫-使用xpath方法

Python方法爬虫 xpath 使用
2023-09-14 09:12:15 时间
#coding=utf-8
import re
from lxml import etree

import requests

response = requests.get("http://yeves.cn/")
content = response.content.decode()

html = etree.HTML(content)
res = html.xpath('/html/body/section/aside/div[1]/div/h3/text()')
print(res)