scrapy没有正确下载文件。我有我的项目的网址,所以我想我可以使用wget下载文件。在
如何在scrapyprocess_item
函数中使用wget?或者,是否有其他下载文件的方式?在
class MyImagesPipeline(ImagesPipeline):
#Name download version
def image_key(self, url):
image_guid = url.split('/')[-1]
return 'full/%s' % (image_guid)
def get_media_requests(self, item, info):
if item['image_urls']:
for image_url in item['image_urls']:
# wget -nH image_ul -P images/
yield Request(image_url)
此代码将执行wget,您可以用以下行替换注释
你可以读到subprocess.call这里:http://docs.python.org/2/library/subprocess.html
相关问题 更多 >
编程相关推荐