我想使用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/
看起来应该很容易,但是在搜索过程中什么都没有发生。
谢谢。