文章詳情頁
python - scrapy 再次請求的問題
瀏覽:121日期:2022-08-17 18:54:48
問題描述
如:item[’url’]=response.xpath(’a/@href’)分析出一個鏈接,然后想從這個鏈接里的網頁再獲取一些元素,放入item[’other’]。應該怎么寫,謝謝。
問題解答
回答1:def parse_page1(self, response): for url in urls:item = MyItem()item[’url’] = urlrequest = scrapy.Request(url,callback=self.parse_page2)# request = scrapy.Request('http://www.example.com/some_page.html',dont_filter=True,callback=self.parse_page2)request.meta[’item’] = itemyield requestdef parse_page2(self, response): item = response.meta[’item’] item[’other’] = response.xpath(’/other’) yield item
最后附上官方文檔https://doc.scrapy.org/en/lat...中文翻譯版http://scrapy-chs.readthedocs...
相關文章:
1. docker網絡端口映射,沒有方便點的操作方法么?2. debian - docker依賴的aufs-tools源碼哪里可以找到啊?3. 關docker hub上有些鏡像的tag被標記““This image has vulnerabilities””4. docker容器呢SSH為什么連不通呢?5. android clickablespan獲取選中內容6. nignx - docker內nginx 80端口被占用7. 前端 - ng-view不能加載進模板8. python - from ..xxxx import xxxx到底是什么意思呢?9. ddos - apache日志很多其它網址,什么情況?10. 請教各位大佬,瀏覽器點 提交實例為什么沒有反應
排行榜
