PPT模板哪里来——02

1——我想要PPT模板

2——Python来实现

# author:
# datetime:2022/6/22 19:30周三
# software: PyCharm
"""
文件说明:
"""
import requests
from lxml import etree
import re
import os
url = 'https://www.1ppt.com/xiazai/jianli/'
ua = {'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36'}
res = requests.get(url, headers=ua)
res.encoding = 'gbk'
response = etree.HTML(res.text)
# 1 获取第一级的标题和对应的链接
link1 = response.xpath('//ul[@class="tplist"]/li/a/@href')
title1 = response.xpath('//ul[@class="tplist"]//@alt')
d = dict(zip(title1, link1))
for n1, url1 in d.items():
    url1 = 'https://www.1ppt.com' + url1
    res2 = requests.get(url1, headers=ua)
    res2.encoding = 'gbk'
    data = etree.HTML(res2.text)
    data = data.xpath('//ul[@class="downurllist"]/li/a/@href')
    url2 = 'https://www.1ppt.com' + data[0]
    res3 = requests.get(url2, headers=ua)
    data3 = etree.HTML(res3.text).xpath('//ul[@class="downloadlist"]/li/a/@href')
    # print(data3[0])
    path1 = 'c://mmm/1PPT模板/'
    if not os.path.exists(path1):
        os.mkdir(path1)
    f_data = requests.get(data3[0], headers=ua).content
    # print(f_data)
    suffix = data3[0].split('.')[-1]
    path1 = path1 + n1 + '.' + suffix
    print(path1)
    with open(path1, 'wb') as ff:
        ff.write(f_data)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值