• 【汽修帮手】数据采集,爬虫,根据pdf文件流合并pdf文件


    # -*- coding:utf-8 -*-
    # @URL: d3d3LnF4YnNrLmNvbQ==
    import requests
    
    def rqu(length):
        with open(f'test.pdf', 'ab+') as f:
            r1 = length
            r2 = r1 + 1048575
            headers = {
                "authority": "www.qxbsk.com",
                "accept": "*/*",
                "accept-language": "zh-CN,zh;q=0.9",
                "cache-control": "no-cache",
                "pragma": "no-cache",
                "range": f"bytes={r1}-{r2}",
                "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
            }
    
            response = requests.get(url, headers=headers, cookies=cookies, params=params, stream=True)
            response.encoding = 'utf-8'
            f.write(response.content)
    
    
    def get_total_length(params):
        response = requests.get(url, headers=headers, cookies=cookies, params=params, stream=True)
        response.encoding = 'utf-8'
        total_length = response.headers['Content-Length']
        return total_length
    
    
    if __name__ == '__main__':
        headers = {
            "authority": "www.qxbsk.com",
            "accept": "*/*",
            "accept-language": "zh-CN,zh;q=0.9",
            "cache-control": "no-cache",
            "pragma": "no-cache",
            "user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
        }
    
        cookies = {
            "security_session_verify": "",
            "home_lang": "cn",
            "admin_lang": "cn",
            "PHPSESSID": ""
        }
        url = "https://www.qxbsk.com/home/test/uploadss"
        params = {
            "file": "OTc5MzQ0",
            "__token__": ""
        }
        totalLength = get_total_length(params)
        print(totalLength)
        if int(totalLength) < 1048576:
            rqu(0)
            print(f"下载中...{totalLength}/{totalLength}")
        else:
            for pLength in range(0, int(totalLength), 1048576):
                rqu(pLength)
                print(f"下载中...{pLength}/{totalLength}")
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
  • 相关阅读:
    磁盘算法——为了减少寻道时间
    结构型设计模式
    7. 堪比JMeter的.Net压测工具 - Crank 总结篇 - crank带来了什么
    springboot13:数据库分析
    03-Android App logger策略
    Qt之QStackedLayout
    关于京东购物车中一个店铺加购商品过多时,店铺名称不被划走的实现
    GBase 8s数据库DB-Access全屏菜单界面介绍(1)
    知乎日报--第四周
    对抗生成网络GAN系列——CycleGAN简介及图片春冬变换案例
  • 原文地址:https://blog.csdn.net/qq_35240081/article/details/136359371