我正在嘗試為 scrapy CrawlSpider restrict_xpaths LinkExtractor 構建一個 Xpath 條件,該條件嘗試查找頁腳中的所有鏈接,如果頁腳不存在,則查找正文中的所有鏈接。如果兩者都存在,則只查找頁腳中的鏈接。
我現在只有這個
restrict_xpaths = ["//footer","//head"]
uj5u.com熱心網友回復:
好答案 :
restrict_xpaths = ["//footer//a | //a[not(//footer)]"]
更普遍 :
narrow[global contition] | wider[not(global condition)]
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/349835.html
