利用python爬取点小图片,满足私欲(爬虫)

 1 import requests
 2 import re
 3 import os,sys
 4 
 5 
 6 
 7 
 8 def get_url(page,headers):
 9     url='http://www.zbjuran.com/mei/xinggan/list_13_%s.html'%(page)
10     data=requests.get(url,headers=headers).text
11     data_use=re.findall('')[0]
35                             with open('/Users/b1ancheng/mzpc/%s/%s_%s.JPG' % (title, title,i),'wb') as pic_download:
36                                 pic_download.write(requests.get(pic_data_link).content)
37                             continue
38                     except Exception as error:
39                         print(error)
40                         continue
41             except Exception as e1:
42                 print(e1)
43                 os.rmdir(mkpath)
44                 pass
45         # 创建目录          //可修改进get_pic
46         isExists = os.path.exists(mkpath)
47         if not isExists:
48             os.makedirs(mkpath)
49             get_pic()
50         else:
51             return False
52 if __name__ == '__main__':
53     headers = {
54         'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_12_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/61.0.3163.100 Safari/537.36',
55         'Host': 'www.zbjuran.com',
56         'Cookie': 'UM_distinctid=15ef9964528386-07264d76850875-31657c00-13c680-15ef9964529361; CNZZDATA1264461841=1179231757-1507422986-null%7C1508056601'
57     }
58     links = []
59     titles = []
60     for page in range(1,88):
61         get_url(page,headers=headers)

望兄多提意见,相互进步

转载于:https://www.cnblogs.com/b1ancheng/p/7671148.html

你可能感兴趣的:(利用python爬取点小图片,满足私欲(爬虫))