我在使用 Scrapy 抓取图像并将结果导出为 CSV 时遇到了一些问题。我的设置是:
FEED_URI = 'export.csv'
FEED_FORMAT = 'csv'
第一个问题是导出为 JSON,而不是 CSV。另一个问题是我希望导出包含 start_urls,所以导出应该是:
start_url, original_image, scraped_image
http://www.bk.com, http://www.bk.com/images/bk-logo-rv.png, http://mysite.com/53948534985374.jpg
这就是我正在运行的命令:
scrapy crawl image_downloader -L ERROR --logfile=log
这就是管道:
class ImageDownloaderPipeline(ImagesPipeline):
def get_media_requests(self, item, info):
for image_url in item['image_urls']:
yield Request(image_url)
def item_completed(self, results, item, info):
image_paths = [x['path'] for ok, x in results if ok]
if not image_paths:
raise DropItem("Item contains no images")
return item
谁能帮帮我?
谢谢!