打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
我用python爬取了上万张手机壁纸后,发现这个网站质量简直 永远的神!

一、准备工作

使用的软件和模块

requests
Python
pycharm
threading

目标

360图片

地址:https://image.so.com

二、效果

根本停不下来



三、代码

import requests
import threading

headers = {
    'User-Agent''Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36'
}


def get_response(html_url):
    response = requests.get(url=html_url, headers=headers)
    return response


def save(img_url, title):
    path = 'img\\' + title + '.jpg'
    img_content = get_response(img_url).content
    with open(path, mode='wb'as f:
        f.write(img_content)
        print('正在保存:', title)


def main(url):
    html_data = get_response(url).json()
    lis = html_data['list']
    for li in lis:
        img_url = li['qhimg_downurl']
        title = li['title']
        save(img_url, title)


if __name__ == '__main__':
    for page in range(030130):
        url = 'https://image.so.com/zjl?ch=beauty&sn={}&listtype=new&temp=1'.format(page)
        main_thread = threading.Thread(target=main, args=(url,))
        main_thread.start()

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
三步爬取半次元热门图片
用Python制作一个每天新闻热点爬虫脚本
python带你采集各种表情包,做群里最靓的崽~
Python丨听说这个地方的漫画不错,只用40行代码,给它全部爬下来
普通爬虫vs多线程爬虫vs框架爬虫,Python爬对比
Python 爬虫实战(二):使用 requests
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服