【发布时间】:2021-12-08 01:43:17
【问题描述】:
我正在尝试抓取此页面 http://kenyalaw.org:8181/exist/kenyalex/actview.xql?actid=CAP.%2016
并且有这个示例 python 代码:
import requests
from lxml import html
r = requests.get("http://kenyalaw.org:8181/exist/kenyalex/actview.xql?actid=CAP.%2016")
data = html.fromstring(r.content)
print(data.xpath("//div[@class='subleg']/a/@href")[0])
这给了我这个输出:
sublegview.xql?subleg=CAP。 16
但是当我在这个 xpath 上使用鼠标悬停时,会有不同的链接,如下图所示:
http://kenyalaw.org:8181/exist/kenyalex/sublegview.xql?subleg=CAP.%2016
【问题讨论】:
标签: python xpath python-requests