Python xpath不包含A和B
我怎样才能补充呢Python xpath不包含A和B,python,xpath,scrapy,Python,Xpath,Scrapy,我怎样才能补充呢 not(包含(,'facebook'),not(包含(,'twitter')到我的xpath sites = selector.xpath("//h3[@class='r']/a[@href[not(contains(.,'google') )]]/@href") 我想找到一个没有google、facebook和twitter的url 请帮助我,谢谢你你可以加入和的条件: //h3[@class='r']/a[not(contains(@href,'google')) a
not(包含(,'facebook')
,not(包含(,'twitter')
到我的xpath
sites = selector.xpath("//h3[@class='r']/a[@href[not(contains(.,'google') )]]/@href")
我想找到一个没有google
、facebook
和twitter
的url
请帮助我,谢谢你你可以加入
和
的条件:
//h3[@class='r']/a[not(contains(@href,'google')) and not(contains(@href,'facebook')) and not(contains(@href,'twitter'))]/@href")
或者,使用选择器上提供的实例:
selector.xpath("//h3[@class='r']/a/@href").re('^(?!.*(google|facebook|twitter)).*$')
此外,您还可以使用:
你需要更加谨慎地明确表达你的要求。我怀疑你想要一个没有谷歌、推特或facebook的url:也就是说,三者中的任何一个都会取消该url的资格,而按照你的书写方式,只有三者都存在时,该url才被取消资格。
selector.xpath("//h3[@class='r']/a[not(re:test(@href, '(google|facebook|twitter)'))]/@href")