Demo entry 6741903

a

   

Submitted by aa on May 17, 2018 at 03:27
Language: Python. Code size: 461 Bytes.

import urllib2
import os
 
class PicPipeline(object):
    def process_item(self, item, spider):
        headers = {'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; WOW64; rv:52.0) Gecko/20100101 Firefox/52.0'}
        req = urllib2.Request(url=item['addr'],headers=headers)
        res = urllib2.urlopen(req)
        file_name = os.path.join(r'D:\my\down_pic',item['name']+'.jpg')
        with open(file_name,'wb') as fp:
            fp.write(res.read())

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).