0
我想抓取鏈接圖像:「http://vnexpress.net/photo/cuoc-song-do-day/nguoi-trung-quoc-ra-be-boi-danh-mat-chuoc-tranh-nong-3445592.html」,但代碼只抓取一張圖片(在我的計算機中)並抓取所有圖片(在我的朋友計算機中)。普萊舍請幫我scrapy只能抓取1張圖片
import scrapy
from scrapy.contrib.spiders import Rule, CrawlSpider
from scrapy.contrib.linkextractors import LinkExtractor
from imgur.items import ImgurItem
class ImgurSpider(CrawlSpider):
name = 'imgur'
allowed_domains = ['vnexpress.net']
start_urls = ['http://vnexpress.net/photo/cuoc-song-do-day/nguoi-trung-quoc-ra-be-boi-danh-mat-chuoc-tranh-nong-3445592.html']
# rules = [Rule(LinkExtractor(allow=['/*']), 'parse123')]
def parse(self, response):
image = ImgurItem()
# image['title'] = response.xpath(\
# "//img[data-notes-url=""]").extract()
rel = response.xpath("//div[@id='article_content']//img/@src").extract()
image['image_urls'] = [rel[0]]
return image
哦,是的,謝謝 –
太棒了!你能接受答案嗎? – Huxwell