从网站上抓取图片

2024-04-25 23:30:03 发布

您现在位置:Python中文网/ 问答频道 /正文

我想从vinnicolas的网站上抓取每瓶葡萄酒的图片并保存在svc文件中。在

不幸的是,我有一些错误:

蜘蛛:https://gist.github.com/anonymous/6424305

在管道.py. :https://gist.github.com/nahali/6434932

在设置.py公司名称:


Tags: 文件pyhttpsgithubcom管道网站错误
1条回答
网友
1楼 · 发布于 2024-04-25 23:30:03

您的parse_wine_page没有在项目中设置“image_url”字段值,因此中间件不会下载任何图像

import urlparse
...

    def parse_wine_page(self, reponse):
        ...
        hxs = HtmlXPathSelector(response)
        content = hxs.select('//*[@id="glo_right"]')
        for res in content:
            ...
            #item ["Image"]= map(unicode.strip, res.select('//div[@class="pro_detail_tit"]//div[@class="pro_titre"]/h1/text()').extract())
            item['image_urls'] = map(lambda src: urlparse.urljoin(response.url, src), res.select('./div[@class="pro_col_left"]/img/@src').extract())
            items.append(item)
        return items

还要确保您的Projetvinnicolas3Item类有“images”和“image\u url”字段()

相关问题 更多 >