现在的大学生都不需要制作ppt的吗,想当年我读大学的时候,连个自我介绍还需要搞个专门的ppt上台给同学介绍自己
自己不会做,只能在网上找模板,但是!好多都需要 💰💰…
这不现在把python学好后,需要用到ppt的次数越来越少了
就分享出来给现在还需要经常做ppt又没啥模板的铁子吧
模块安装问题:
如果安装python第三方模块:
安装失败原因:
失败一: pip 不是内部命令
解决方法: 设置环境变量
失败二: 出现大量报红 (read time out)
解决方法: 因为是网络链接超时, 需要切换镜像源
清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:https://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:https://pypi.hustunique.com/
山东理工大学:https://pypi.sdutlinux.org/
豆瓣:https://pypi.douban.com/simple/
例如:pip3 install -i https://pypi.doubanio.com/simple/ 模块名
【也可以在代码中的q群领取】
# 导入格式化输出模块
import pprint
# 导入数据请求模块
import requests # 导入模块没有使用, 会是一个灰色待机状态... pip install requests
# 导入正则表达式模块
import re # 内置模块 不需要安装
# 导入多线程模块
import concurrent.futures
def get_response(html_url):headers = {690643772 ### 源码领取'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36'}dit = get_proxy()response = requests.get(url=html_url, headers=headers, proxies=dit)response.encoding = 'utf-8'return response
获取ppt id 以及 标题
def get_ppt_info(html_url):response = get_response(html_url)data_list = re.findall('(.*?)', response.text)return data_list
def save(link, title):response_1 = get_response(link)download_url = re.findall('下载地址1 ', response_1.text)[0]ppt_content = get_response(download_url).contentwith open('素材\\' + title + '.zip', mode='wb') as f:f.write(ppt_content)print('保存成功: ', title)
把所有的功能函数整合到一起
def main(html_url):data_list = get_ppt_info(html_url)for link, title in data_list:690643772 ### 源码领取ppt_id = link.split('/')[-1][:-5]ppt_url = f'https://www.ypppt.com/p/d.php?aid={ppt_id}'save(ppt_url, title)if __name__ == '__main__':exe = concurrent.futures.ThreadPoolExecutor(max_workers=5)for page in range(2, 11): # 2,3,4,5,6,7,8,9,10url = f'https://www.ypppt.com/moban/list-{page}.html/' # 确定urlexe.submit(main, url)exe.shutdown()
文章分享到这里就结束了,希望对你们都有所帮助
如果有什么不理解的地方,可以私信我的哈
下一篇:c++文件读取