吾爱破解 - 52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 969|回复: 13
收起左侧

[下载转存] 求转存几本电子书

[复制链接]
头像被屏蔽
hkty1 发表于 2024-5-25 14:38
提示: 作者被禁止或删除 内容自动屏蔽

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

goodname521 发表于 2024-5-25 14:39
https://f.ws59.cn/f/e7juczvp21c 复制链接到浏览器打开
candyes 发表于 2024-5-26 23:37
哥,能帮忙下载蜻蜓FM里面的《茅山后裔》姚科演播的音频吗
头像被屏蔽
 楼主| hkty1 发表于 2024-5-27 08:43
haijing1987 发表于 2024-5-27 16:04
goodname521 发表于 2024-5-27 09:01
https://f.ws59.cn/f/e7juczvp21c 复制链接到浏览器打开

是怎么下载的啊,可以分享下教程不
goodname521 发表于 2024-5-27 16:18
haijing1987 发表于 2024-5-27 16:04
是怎么下载的啊,可以分享下教程不

他这个网站的资源F12能看到所有图片的链接,get请求直接就能下载,写的程序下载的
下面是gpt转的python 不知道能不能跑
[Python] 纯文本查看 复制代码
import requests
import re
import os
from concurrent.futures import ThreadPoolExecutor, as_completed
from PIL import Image
from pdf2image import convert_from_path
from fpdf import FPDF

# Constants
JS_URL = "/mobile/javascript/config.js"
IMG_URL = "/files/mobile/"  # High resolution
# IMG_URL = "/files/thumb/"  # Thumbnail

class Book:
    def __init__(self, title, page_num, url):
        self.title = title
        self.page_num = page_num
        self.url = url

def get_javascript(url):
    response = requests.get(url)
    return response.text

def extract_config_value(js_content, pattern):
    r = re.compile(pattern)
    m = r.search(js_content)
    if m:
        return m.group(1)
    else:
        return None

def download_image(image_url, index):
    response = requests.get(image_url, stream=True)
    if response.status_code == 200:
        image_path = f"image-{index}.jpg"
        with open(image_path, 'wb') as f:
            f.write(response.content)
        return image_path
    else:
        return None

def create_pdf(book):
    pdf = FPDF(unit="pt", format=(1000, 1000))  # Adjust format based on typical image size
    for i in range(1, book.page_num + 1):
        image_url = f"{book.url}{i}.jpg"
        image_path = download_image(image_url, i)
        if image_path:
            img = Image.open(image_path)
            width, height = img.size
            pdf.add_page()
            pdf.image(image_path, x=0, y=0, w=width, h=height)
            os.remove(image_path)  # Clean up downloaded image
    pdf_path = f"{book.title}.pdf"
    pdf.output(pdf_path)
    print(f"PDF generated: {pdf_path}")

def main():
    urls = [
        "https://dfz.zj.gov.cn/zlyz/ossfs//h5/ZS-Z-330383-2009-001-0101/",
        # ... other URLs ...
    ]

    books = []

    for url in urls:
        js_content = get_javascript(url + JS_URL)
        book_title = extract_config_value(js_content, r"bookConfig\.bookTitle=\"([^\"]+)\"")
        total_count = int(extract_config_value(js_content, r"bookConfig\.totalPageCount=(\d+)"))

        print(f"Book Title: {book_title}")
        print(f"Total Page Count: {total_count}")
        book = Book(book_title, total_count, url + IMG_URL)
        books.append(book)

    with ThreadPoolExecutor(max_workers=os.cpu_count()) as executor:
        for book in books:
            executor.submit(create_pdf, book)

if __name__ == "__main__":
    main()
小众资源 发表于 2024-5-28 09:40
goodname521 发表于 2024-5-27 16:18
他这个网站的资源F12能看到所有图片的链接,get请求直接就能下载,写的程序下载的
下面是gpt转的python  ...



  抽时间写了个小工具,下午在加入生成PDF
goodname521 发表于 2024-5-28 13:56
小众资源 发表于 2024-5-28 09:40
抽时间写了个小工具,下午在加入生成PDF

大佬!应该回复给楼上
@haijing1987 @hkty1
haijing1987 发表于 2024-5-29 11:47
小众资源 发表于 2024-5-28 09:40
抽时间写了个小工具,下午在加入生成PDF

可以把工具分享不
小众资源 发表于 2024-5-29 18:46
haijing1987 发表于 2024-5-29 11:47
可以把工具分享不

可以呀,我本来是发原创区的,懒得写文案被退回来啦,你开个求助帖,我回复吧

免费评分

参与人数 1热心值 +1 收起 理由
ad9528 + 1 这就叫专业

查看全部评分

您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

返回列表

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-12-15 07:43

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表