0
リンクのクロール画像を希望します:「http://vnexpress.net/photo/cuoc-song-do-day/nguoi-trung-quoc-ra-be-boi-danh-mat-chuoc-tranh-nong-3445592.html」しかし、コードは(自分のコンピュータで)画像をクロールし、(友人のコンピュータで)すべての画像をクロールします。 pleseはあなたが[0]のインデックスを指定することにより、1つのリンクのみを取る傷病専用クロール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