python之秀人网图片下载
Published on 2023-12-28 13:11 in 分类: python with 萧海~
分类: python

python之秀人网图片下载

    import requests
    from lxml import etree
    cookies = {
    '_pk_ref.2.90a9': '%5B%22%22%2C%22%22%2C1703739850%2C%22https%3A%2F%2Fwww.google.com.hk%2F%22%5D',
    '_pk_id.2.90a9': 'b87f72074fff4914.1703739850.',
    '_pk_ses.2.90a9': '1',
    }
    headers = {
    'authority': 'www.xiurenwang.cc',
    'accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7',
    'accept-language': 'zh-CN,zh;q=0.9',
    'cache-control': 'no-cache',
    # Requests sorts cookies= alphabetically
    # 'cookie': '_pk_ref.2.90a9=%5B%22%22%2C%22%22%2C1703739850%2C%22https%3A%2F%2Fwww.google.com.hk%2F%22%5D; _pk_id.2.90a9=b87f72074fff4914.1703739850.; _pk_ses.2.90a9=1',
    'pragma': 'no-cache',
    'referer': 'https://www.xiurenwang.cc/bang',
    'sec-ch-ua': '"Not_A Brand";v="8", "Chromium";v="120", "Google Chrome";v="120"',
    'sec-ch-ua-mobile': '?0',
    'sec-ch-ua-platform': '"Windows"',
    'sec-fetch-dest': 'document',
    'sec-fetch-mode': 'navigate',
    'sec-fetch-site': 'same-origin',
    'sec-fetch-user': '?1',
    'upgrade-insecure-requests': '1',
    'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
    }
    response = requests.get('https://www.xiurenwang.cc/bang/page/2', cookies=cookies, headers=headers)
    # print(response.text)
    html=etree.HTML(response.text)
    next_url=html.xpath('//div[@class="list"]/li/a[@class="img"]/@href')
    for item in next_url:
    detail_url='https://www.xiurenwang.cc'+item
    response = requests.get(detail_url, cookies=cookies, headers=headers)
    html = etree.HTML(response.text)
    img_url = html.xpath('//div[@id="image"]/a/@href')
    print(img_url)

    posted @   萧海~  阅读(2369)  评论(0编辑  收藏  举报
    相关博文:
    阅读排行:
    · winform 绘制太阳,地球,月球 运作规律
    · AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
    · 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
    · 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
    · 上周热点回顾(3.3-3.9)
    历史上的今天:
    2020-12-28 MFC-自定义消息
    2020-12-28 MFC-窗口操作
    2020-12-28 Mbedtls-随机数测试
    2020-12-28 C语言中 %02X 是什么意思
    2020-12-28 MFC-屏蔽esc键和enter键
    2020-12-28 txt文本中,一行最大字符数是多少,文本最大行数是多少
    2020-12-28 WIndows判断路径是否存在
    点击右上角即可分享
    微信分享提示
    电磁波切换