【爬虫】在Xpath中使用正则

ns = {"re": "http://exslt.org/regular-expressions"}
print(html.xpath("//*[re:match(text(), 正则表达式)]/text()", namespaces=ns))

是有关命名空间namespace的知识,之前在文档中找到的答案,现在不知道为什么打不开官网,无法指出具体出处。

猜你喜欢

转载自www.cnblogs.com/XD00/p/10626301.html