比如下面图片中的这段代码,只想选取id为数字的div标签,就可以在XPath中使用正则表达式:
response.xpath('//form/div[re:match(@id, "\d+")]')
#注意 re:match 
参考来源:How to use regular expression in lxml xpath?
» 本文来自:乌帮图 » 《XPath选择器中的正则表达式》
» 链接地址:https://wbt5.com/xpath-re.html »英雄不问来路,转载请注明出处。