爬取昵图网

一、爬取昵图网

import re
import requests
"""
@author RansySun
@create 2019-07-22-11:19
"""
# 请求链接地址
response = requests.get('http://www.nipic.com/design/acg/renwu/index.html?page=1')
data = response.text
res_data = re.findall('data-src="(.*?)"', data)

# 获取图片
for res in res_data:
    print(res)
    img_response = requests.get(res)
    img_data = img_response.content
    img_name = res.split("/")[-1]
    fw = open(img_name, "wb")
    fw.write(img_data)
    print("成功")
    fw.flush()

posted @ 2019-07-23 14:54  RandySun  阅读(1173)  评论(1编辑  收藏  举报