利用爬虫代码美女写真套图下载转PDF保存【和平精英直装免卡密】

  发布时间:2025-11-03 14:06:26   作者:玩站小弟   我要评论
爬的利用不是全站链接,该爬虫爬的爬虫和平精英直装免卡密是每套图的链接,相当于是代码和平精英地铁逃生详情页的链接需要单独下载的python库requestsfake_useragentxpathPIL下面有图片 打码是为了过审,这网站真的美女和平精英灵敏度怎么调最稳是正经的写真网站不是什么老司机网站import requests from fake_useragent import UserAgent from lxml import etree import os import aiohttp import asyncio from PIL import Image import shutil #获取详情页全部图片函数 async def get_xq(url): #计数 p=0 tasks = [] res = requests.get(url=url,headers=header) res.encoding="utf-8" res.close() tree = etree.HTML(res.text) #图片标题 imgtitle = tree.xpath(//title/text())[0] global title title = imgtitle #第一页的图片链接 img = tree.xpath(//article//img/@src) imgurl = ["https://www.xgyw01.co" + i for i in img] print("当前下载的套图标题:\n"+imgtitle) for i in imgurl: p += 1 tasks.append(down(i,imgtitle,p)) #获取下一页的链接 next = "https://www.xgyw01.co" + tree.xpath(//div[@class="pagination"][1]//a[last()]/@href)[0] #判断的条件 bool = tree.xpath(//div[@class="pagination"][1]//a[last()]/text())[0] #循环获取所有页 while True: print("正在获取"+next) if bool == "下一页" or bool == "下页": res = requests.get(url=next, headers=header) res.encoding = "utf-8" res.close() tree = etree.HTML(res.text) img = tree.xpath(//article//img/@src) imgurl = ["https://www.xgyw01.co" + i for i in img] for i in imgurl: p += 1 tasks.append(down(i,imgtitle,p)) #判断的条件 bool = tree.xpath(//div[@class="pagination"][1]//a[last()]/text())[0] if bool == "下一页" or bool == "下页": next = "https://www.xgyw01.co" + tree.xpath(//div[@class="pagination"][1]//a[last()]/@href)[0] continue else: break else: break print("开始异步下载图片.....") await asyncio.wait(tasks) #下载函数 async def down(url,filename,fn): filepath = os.path.join(dirdz,filename) if not os.path.exists(filepath): os.mkdir(filepath) async with aiohttp.ClientSession() as session: async with session.get(url) as res: with open(filepath+"/"+str(fn)+".jpg",mode="wb") as f: f.write(await res.content.read()) print(f"第{fn}张下载完成") #写真图片转PDF函数 def jpg_pdf(filename): # 定义文件夹路径和PDF文件名 folder_path = os.path.join(dirdz,filename) pdf_filename = os.path.join(dirdz,filename + ".pdf") # # 将JPEG文件转换为Pillow Image对象并添加到列表中 image_files = [os.path.join(folder_path, f) for f in os.listdir(folder_path) if f.endswith(.jpeg) or f.endswith(.jpg)] image_list = [] for file_path in image_files: img = Image.open(os.path.abspath(file_path)) image_list.append(img) # 找到所有JPEG文件 image_list[0].save(pdf_filename, "PDF" ,resolution=100.0, save_all=True, append_images=image_list[1:]) print("pdf合并完成,删除缓存的的图片") shutil.rmtree(folder_path) print("清理完成") #主函数 if __name__ == __main__: #定义的公共请求头 header = {"user-agent": UserAgent().random} #定义的保存路径(文件夹路径) dirdz = "这里输入保存的文件夹路径" #定义一个全局的标题保存文件名字 title = "" #爬取的网站是:https://www.xgyw01.co/,找到想下的写真下载和平精英科技套图直接点进去复制详情页的链接就行了 url = input("请输入套图详情页链接:") #使用异常捕获排除异常 try: #因为是异步函数所以需要用asyncio.run启动 asyncio.run(get_xq(url)) print(title) except: print("链接详情页解析错误.........") print("全部下载完成,开始生成pdf.......") #调用图片转PDF函数 jpg_pdf(title) 。

爬的利用不是全站链接,该爬虫爬的爬虫和平精英直装免卡密是每套图的链接,相当于是代码和平精英地铁逃生详情页的链接

需要单独下载的python库

利用爬虫代码美女写真套图下载转PDF保存【和平精英直装免卡密】

requests

利用爬虫代码美女写真套图下载转PDF保存【和平精英直装免卡密】

fake_useragent

利用爬虫代码美女写真套图下载转PDF保存【和平精英直装免卡密】

xpath

PIL

下面有图片 打码是为了过审,这网站真的美女和平精英灵敏度怎么调最稳是正经的写真网站不是什么老司机网站

import requests from fake_useragent import UserAgent from lxml import etree import os import aiohttp import asyncio from PIL import Image import shutil #获取详情页全部图片函数 async def get_xq(url): #计数 p=0 tasks = [] res = requests.get(url=url,headers=header) res.encoding="utf-8" res.close() tree = etree.HTML(res.text) #图片标题 imgtitle = tree.xpath(//title/text())[0] global title title = imgtitle #第一页的图片链接 img = tree.xpath(//article//img/@src) imgurl = ["https://www.xgyw01.co" + i for i in img] print("当前下载的套图标题:\n"+imgtitle) for i in imgurl: p += 1 tasks.append(down(i,imgtitle,p)) #获取下一页的链接 next = "https://www.xgyw01.co" + tree.xpath(//div[@class="pagination"][1]//a[last()]/@href)[0] #判断的条件 bool = tree.xpath(//div[@class="pagination"][1]//a[last()]/text())[0] #循环获取所有页 while True: print("正在获取"+next) if bool == "下一页" or bool == "下页": res = requests.get(url=next, headers=header) res.encoding = "utf-8" res.close() tree = etree.HTML(res.text) img = tree.xpath(//article//img/@src) imgurl = ["https://www.xgyw01.co" + i for i in img] for i in imgurl: p += 1 tasks.append(down(i,imgtitle,p)) #判断的条件 bool = tree.xpath(//div[@class="pagination"][1]//a[last()]/text())[0] if bool == "下一页" or bool == "下页": next = "https://www.xgyw01.co" + tree.xpath(//div[@class="pagination"][1]//a[last()]/@href)[0] continue else: break else: break print("开始异步下载图片.....") await asyncio.wait(tasks) #下载函数 async def down(url,filename,fn): filepath = os.path.join(dirdz,filename) if not os.path.exists(filepath): os.mkdir(filepath) async with aiohttp.ClientSession() as session: async with session.get(url) as res: with open(filepath+"/"+str(fn)+".jpg",mode="wb") as f: f.write(await res.content.read()) print(f"第{fn}张下载完成") #写真图片转PDF函数 def jpg_pdf(filename): # 定义文件夹路径和PDF文件名 folder_path = os.path.join(dirdz,filename) pdf_filename = os.path.join(dirdz,filename + ".pdf") # # 将JPEG文件转换为Pillow Image对象并添加到列表中 image_files = [os.path.join(folder_path, f) for f in os.listdir(folder_path) if f.endswith(.jpeg) or f.endswith(.jpg)] image_list = [] for file_path in image_files: img = Image.open(os.path.abspath(file_path)) image_list.append(img) # 找到所有JPEG文件 image_list[0].save(pdf_filename, "PDF" ,resolution=100.0, save_all=True, append_images=image_list[1:]) print("pdf合并完成,删除缓存的的图片") shutil.rmtree(folder_path) print("清理完成") #主函数 if __name__ == __main__: #定义的公共请求头 header = {"user-agent": UserAgent().random} #定义的保存路径(文件夹路径) dirdz = "这里输入保存的文件夹路径" #定义一个全局的标题保存文件名字 title = "" #爬取的网站是:https://www.xgyw01.co/,找到想下的写真下载和平精英科技套图直接点进去复制详情页的链接就行了 url = input("请输入套图详情页链接:") #使用异常捕获排除异常 try: #因为是异步函数所以需要用asyncio.run启动 asyncio.run(get_xq(url)) print(title) except: print("链接详情页解析错误.........") print("全部下载完成,开始生成pdf.......") #调用图片转PDF函数 jpg_pdf(title)

相关文章

  • 网站监控/定时任务/网址url监控神器

    源码简介网站监控/定时任务/网址url监控神器 ,可以自己添加url任务,充值改为卡密充值。是一款在线监控网址的一个源码,使用方法0.(可选)编辑根目录下"install.sql",修改第115行对应的
    2025-11-03
  • 小虎队软件库

    小虎队软件库(小虎社)是一款资源丰富的软件下载平台  ,游戏,小说 ,科学,影视 ,漫画等等都应有尽有 ,覆盖率非常高 ,并且这里的资源会不断更新与增加,可以任意下载安装,下载速度还很快,十分稳定,有需要的伙伴 ,
    2025-11-03
  • 快爆手游

    快爆手游是一款拥有丰富游戏资源的游戏盒子app,平台中将为用户提供海量新游 ,更有排行榜等你来体验 ,让用户能够通过软件轻松获得更多优质游戏推荐,快爆手游中将会为用户提供超多的功能,帮助用户能够轻松进入游
    2025-11-03
  • 汇游乐园游戏盒子

    汇游乐园游戏盒子是一款汇聚了大量游戏资源的下载平台,这里提供了许多高质量的游戏资源,都可以免费下载安装,可以搜索游戏关键词来查找你想玩的游戏 ,轻松打发时间,还有各种排行榜可以查看,发现更多有趣的宝藏游
    2025-11-03
  • 解决app误报毒 可打包APP可上传APK 自动实现5分钟随机更换包名和签名系统源码

    源码介绍解决app误报毒 可打包APP可上传APK 自动实现5分钟随机更换包名和签名系统源码本程序功能介绍 :程序可实现域名自动打包成app出现误报毒并自动更换包名和签名*时间一次)也可以上传打包好的a
    2025-11-03
  • 野草助手tv电视版

    野草助手tv电视版是一款非常实用的应用安装与分享工具,可以通过输入口令的方式来安装需要的各种应用 ,还提供了多种安装方式可以选择 ,并且下载速度也很快 ,轻松好上手,界面也很简洁 ,给你舒适的使用体验,有需要
    2025-11-03

最新评论