知乎高清原图下载python极简脚本

1.脚本,注意修改保存目录和爬取链接

# 爬取的知乎文字
#本例爬取 《已续更wlop鬼刀高清壁纸系列4K8K都有不多说看图全知乎放上来最多最好的好吧✧*。٩(ˊωˋ*)و✧*鬼刀wlop》
import requests
import os
from lxml import etree

dir_name = 'pic1' #1.需要修改:设置需要保存的文件夹的名字
 
if not os.path.exists(dir_name): #os模块判断文件夹是否存在并创建
    os.mkdir(dir_name)

link= 'https://zhuanlan.zhihu.com/p/107129943' #2.需要指定爬取的文章链接


headers={'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 '
                      '(KHTML, like Gecko) Chrome/87.0.4280.88 '
                      'Safari/537.36 Edg/87.0.664.66'}
r=requests.get(url=link,headers=headers)

html=etree.HTML(r.content)
title_list=html.xpath('//figure[*]/img')
for item in title_list:
    img_url = item.xpath('./@data-original')[0]
    print(img_url)
    picture_name = img_url.split('/')[-1].split('?')[0]
    print('picture_name:' + picture_name)
    reponse = requests.get(img_url)
    with open('./'+ dir_name + '/'+picture_name,'wb') as f:
        f.write(reponse.content)

2.爬取结果,均为高清图

在这里插入图片描述

3.脚本执行效果

在这里插入图片描述
原文地址:
知乎高清原图下载python极简脚本

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值