【三角洲科技辅助官网】利用爬虫代码美女写真套图下载转PDF保存

  发布时间:2025-11-02 21:44:13   作者:玩站小弟   我要评论
爬的利用不是全站链接,该爬虫爬的爬虫三角洲科技辅助官网是每套图的链接,相当于是代码三角洲pc科技群详情页的链接需要单独下载的python库requestsfake_useragentxpathPIL下面有图片 打码是为了过审,这网站真的美女三角洲pc科技公益下载是正经的写真网站不是什么老司机网站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/,找到想下的写真下载三角洲pc科技购买 软件介绍套图直接点进去复制详情页的链接就行了 url = input("请输入套图详情页链接:") #使用异常捕获排除异常 try: #因为是异步函数所以需要用asyncio.run启动 asyncio.run(get_xq(url)) print(title) except: print("链接详情页解析错误.........") print("全部下载完成,开始生成pdf.......") #调用图片转PDF函数 jpg_pdf(title) 。

爬的利用不是全站链接,该爬虫爬的爬虫三角洲科技辅助官网是每套图的链接 ,相当于是代码三角洲pc科技群详情页的链接

需要单独下载的python库

【三角洲科技辅助官网】利用爬虫代码美女写真套图下载转PDF保存

requests

fake_useragent

xpath

PIL

下面有图片 打码是为了过审,这网站真的美女三角洲pc科技公益下载是正经的写真网站不是什么老司机网站

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/  ,找到想下的写真下载三角洲pc科技购买 软件介绍套图直接点进去复制详情页的链接就行了 url = input("请输入套图详情页链接:") #使用异常捕获排除异常 try: #因为是异步函数所以需要用asyncio.run启动 asyncio.run(get_xq(url)) print(title) except: print("链接详情页解析错误.........") print("全部下载完成,开始生成pdf.......") #调用图片转PDF函数 jpg_pdf(title)

相关文章

  • 2023全新小西瓜API系统集合系统源码

    源码简介2023全新小西瓜API系统集合系统源码安装教程:访问 http://你的域名/install 进行安装下载地址此处内容需要回复后才能查看
    2025-11-02
  • 上帝点击器中文版

    上帝点击器中文版是一款充满趣味的休闲类游戏,超多内容与享受,给你带来视觉和玩法的双重享受  ,合成创建各种各样的植物来打造一个属于自己的生活 ,来创造自己想象中的万物,喜欢的话就来下载上帝点击器中文版体验一
    2025-11-02
  • 花钱变首富官方正版

    花钱变首富官方正版是一款非常有趣的模拟经营类游戏,游戏的内容特别精彩 ,让你更加的富有 ,在游戏里玩家扮演了一个老板 ,凭借着自己的实力和经验发展自己的行业 ,只要凭借着自己的勇气勇往直前,相信一定会取得胜利
    2025-11-02
  • 英雄大作战全英雄版

    英雄大作战全英雄版是一款非常好玩的街机动作冒险手游 ,游戏提供了多样化的玩法游戏作战方式多样,游戏还有非常多的武器你可以解锁 ,战斗场面超燃,打斗过程中还有炫酷的特效,为您带来复古的体验 ,喜欢竞技的玩家赶
    2025-11-02
  • 影视网站搭建与加盟合作优化引流解析引导页html源码

    源码介绍:一款非常好用的影视网站搭建与加盟合作优化引流解析引导页html源码,只要修好html源码即可使用 ,可做会员介绍解析引导页用下载地址 :此处内容需要回复后才能查看
    2025-11-02
  • 模拟小战争2手机版

    模拟小战争2手机版是一款特别好玩且逼真刺激的冒险射击游戏。通过精致的画面和丰富的玩法,为玩家打造了一个真实战场的体验,通过去战斗来提升自己的战斗力 ,如果你喜欢战争类射击游戏 ,那就赶快下载体验吧 。模拟小
    2025-11-02

最新评论