小编Str*_*man的帖子

使用Python请求提取href URL

我想使用python中的request包从xpath提取URL。我可以得到文本,但没有尝试给出URL。有人可以帮忙吗?

ipdb> webpage.xpath(xpath_url + '/text()')
['Text of the URL']
ipdb> webpage.xpath(xpath_url + '/a()')
*** lxml.etree.XPathEvalError: Invalid expression
ipdb> webpage.xpath(xpath_url + '/href()')
*** lxml.etree.XPathEvalError: Invalid expression
ipdb> webpage.xpath(xpath_url + '/url()')
*** lxml.etree.XPathEvalError: Invalid expression
Run Code Online (Sandbox Code Playgroud)

我使用本教程开始学习:http : //docs.python-guide.org/en/latest/scenarios/scrape/

看起来应该很容易,但是在搜索过程中什么都没有发生。

谢谢。

python xpath lxml python-3.x python-requests

1
推荐指数
2
解决办法
1万
查看次数

标签 统计

lxml ×1

python ×1

python-3.x ×1

python-requests ×1

xpath ×1