How do you scrape images with Scrapy?

吃可爱长大的小学妹 提交于 2020-04-18 12:33:54

问题


I have tried many solutions but I am unable to scrape images with Scrapy. Can Someone can teach me how to scrape images using Scrapy?

Here is my complete code.

Spider:

import scrapy
import datetime
from ..items import ImagesItem
class image(scrapy.Spider):
    name = 'img'
    start_urls = [
        'https://www.allhindilyrics.com/lyrics/nachan-nu-jee-karda-from-angrezi-medium'
    ]

def parse(self, response):

    items = ImagesItem()
    image_url = response.xpath('//*[@id="polular"]/div[1]/div/div/div/a/img').extract()
    items['image_urls'] = image_url
    return items

My items.py:

import scrapy
class ImagesItem(scrapy.Item):
    image_urls = scrapy.Field()
    images = scrapy.Field()

I have also enabled a pipeline with file storage. Please help me with this as I am new to Python and I really need help.

来源:https://stackoverflow.com/questions/60580141/how-do-you-scrape-images-with-scrapy

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!