你好,這是我第一次後,Scrapy分頁失敗
所以我試圖讓網絡蜘蛛會遵循invia.cz鏈接,並從酒店複製所有的標題。
import scrapy
y=0
class invia(scrapy.Spider):
name = 'Kreta'
start_urls = ['https://dovolena.invia.cz/?d_start_from=13.01.2017&sort=nl_sell&page=1']
def parse(self, response):
for x in range (1, 9):
yield {
'titles':response.css("#main > div > div > div > div.col.col-content > div.product-list > div > ul > li:nth-child(%d)>div.head>h2>a>span.name::text"%(x)).extract() ,
}
if (response.css('#main > div > div > div > div.col.col-content >
div.product-list > div > p >
a.next').extract_first()):
y=y+1
go = ["https://dovolena.invia.cz/d_start_from=13.01.2017&sort=nl_sell&page=%d" % y]
print go
yield scrapy.Request(
response.urljoin(go),
callback=self.parse
)
在這個網站的網頁加載與AJAX,所以我手動更改URL的值,由一個僅如果下一步按鈕出現在頁面遞增。
在scrapy shell中,當我測試按鈕是否出現,條件一切都很好時,但是當我啓動蜘蛛時,它只抓取第一頁。
這是我的第一個蜘蛛,所以在此先感謝。
另外,埃勒爾日誌Error Log1Error Log
請分享日誌,什麼是你的錯誤? – eLRuLL
@eLRuLL我發佈了錯誤日誌,如果你想檢查他們 – Kostas
@Granitosaurus你檢查了代碼? – Kostas