美文网首页
Python 爬取斗图网站

Python 爬取斗图网站

作者: shawn_qi | 来源:发表于2018-03-19 01:38 被阅读0次

python3.6

import requests
import re

for n in range(1,51):
    html = requests.get('http://www.doutula.com/photo/list/?page={}'.format(n)).content

    image_url = re.findall('data-original="(.*?)!dta"',html.decode())

    for i in image_url:
        image = requests.get(i).content
        image_name_list = i.split('/')
        image_name = image_name_list[-1]
        f = open(image_name,'wb')
        f.write(image)
        f.close()

    print('爬取完成第{}页'.format(n))

相关文章

网友评论

      本文标题:Python 爬取斗图网站

      本文链接:https://www.haomeiwen.com/subject/pdquqftx.html