zoukankan      html  css  js  c++  java
  • 爬取斗图

    一、 爬取斗图

    import re
    import requests
    """
    @author RansySun
    @create 2019-07-22-17:18
    """
    for i in range(1, 16):
        response = requests.get(f'https://www.doutula.com/photo/list/?page={i}')
        data = response.text
    
        """
        <img referrerpolicy="no-referrer" src="http://ww2.sinaimg.cn/bmiddle/9150e4e5gy1g58b6qkhgzj2095095t8x.jpg" style=" 100%; height: 196px;" data-original="http://ww2.sinaimg.cn/bmiddle/9150e4e5gy1g58b6qkhgzj2095095t8x.jpg" alt="滚呐" class="img-responsive lazy image_dta loaded" data-backup="http://img.doutula.com/production/uploads/image/2019/07/22/20190722785359_osqLXz.jpg" data-was-processed="true">
        
        """
        img_res = re.findall('data-original="(.*?)"', data)
        for res in img_res:
            img_response = requests.get(res)
            img_data = img_response.content
            img_name = res.split("/")[-1]
            print(res)
            with open(img_name, "wb") as fw:
                fw.write(img_data)
                fw.flush()
                print("成功")
    
    
    
    在当下的阶段,必将由程序员来主导,甚至比以往更甚。
  • 相关阅读:
    Redis基础用法
    SpringCloud
    Excel数据导入数据库
    MySQL数据库汇总
    Java8stream表达式
    LocalDateTime&LocalDate&LocalTime
    深入理解Java中的锁
    数据集合
    平台介绍
    dubbo源码阅读之自适应扩展
  • 原文地址:https://www.cnblogs.com/randysun/p/11231928.html
Copyright © 2011-2022 走看看