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

  发布时间:2025-11-04 05:05:21   作者:玩站小弟   我要评论
爬的利用不是全站链接,该爬虫爬的爬虫和平精英直装下载是每套图的链接,相当于是代码自瞄透视辅助器详情页的链接需要单独下载的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)

相关文章

  • H5创意交互式个人简历手机页面模板html源码

    源码介绍H5创意交互式个人简历手机页面模板html源码 ,具有来电式和聊天式交互方案,非常适合于个人使用。该模板可用于展示个人简历、技能介绍、作品展示以及联系方式等信息。该模板采用了魔方样式的导航 ,给用
    2025-11-04
  • 写锤子检讨书2.0

    写锤子检讨书2.0是一款能够帮助用户完成检讨书文案内容生成的工具app ,软件中将会为用户提供众多不同主题检讨书的模板内容,让用户能够一键完成生成,写锤子检讨书2.0中将能够自由设置文案字数,让用户能够
    2025-11-04
  • 通通AI

    通通AI是一款趣味性的ai社交软件,用户将在这里结识更多有趣的朋友,与志同道合的伙伴在线谈天说地,也可以在线记录自己的生活 ,一键分享 ,还可以在线查看其他人的动态,在评论区讨论交流 ,并且还有许多兴趣圈子
    2025-11-04
  • 仁易招找活版

    仁易招找活版这是一款专门用于求职的生活类软件  ,在这款软件之上你可以选择合适自己的工作进行简历的投递 ,无论是你是想找全职又或者是兼职,这里都有很多公司岗位等待着你的加入 ,全方面的职业类型  ,为不同的求职者
    2025-11-04
  • 2023最新Telegram网页版飞机DH源码

    源码简介2023最新telegram网页版飞机DH源码无论手机还是电脑访问,前端均与 官网TG一模一样, 最后一页的提示内容在后台可以设置 , 后台展示必要信息  ,包括
    2025-11-04
  • 胡桃工具箱手机版

    胡桃工具箱手机版是一款能够为用户提供众多游戏辅助的工具app,能够为用户提供众多辅助工具的服务,让用户能够免费体验众多辅助工具,胡桃工具箱手机版在平台中搭载众多辅助工具的跳转链接,帮助用户能够一键直达
    2025-11-04

最新评论