吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 3913|回复: 14
收起左侧

[Python 转载] 若兰格 电子PDF 网盘提取工具

[复制链接]
HonDmOon 发表于 2018-9-26 12:51
本帖最后由 HonDmOon 于 2018-9-26 16:09 编辑

重新修改

修改网页模式

使用pip安装所需要的库
python3 -m pip install  beautifulsoup4

执行
python3 pdf_download.py

访问网址
loaclhost:2000

选区_003.jpg
选区_002.jpg
pdf_download.zip (4.09 KB, 下载次数: 20)


若蓝阁 电子PDF 网盘下载地址提取

ifblue.net pdf下载 ifblue.net
根据关键次搜索提取pdf的下载地址,利用云盘精灵API得到下载地址的提取密码

# python3 代码
# 需要安装 requests 和 BeautifulSoup
# 从若兰格提取 pdf

import requests
from bs4 import BeautifulSoup as bp4
import json

BaiDuAPI_URL = "http://ypsuperkey.meek.com.cn/api/v1/items/BDY-{0}?client_version=2018.11"

# 设置代{过}{滤}理

def req(url_para):
    headers = {
        'Host': 'ypsuperkey.meek.com.cn',
        'User-Agent': 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:62.0) Gecko/20100101 Firefox/62.0',
        'Accept': '*/*',
        'Accept-Language': 'zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2',
        'Connection': 'close',
    }
    req = requests.get(BaiDuAPI_URL.format(url_para),headers = headers)

    if req.status_code == 200:
        return req.text
    return ''
    # print(req.text)

# =============================================================================
RUGE_HOME = "http://www.ifblue.net/"
RUGE_SEARCH_URL = "http://www.ifblue.net/search/{0}/page/{1}"

headers = {
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8',
    'Accept-Encoding': 'gzip, deflate',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Cache-Control': 'max-age=0',
    'Connection': 'keep-alive',
    'DNT': '1',
    'Host': 'www.ifblue.net',
    'Upgrade-Insecure-Requests': '1',
'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/66.0.3359.181 Safari/537.36',
}

def req_html(url):

    req = requests.get(url,headers=headers)

    if req.status_code == 200:
        return req.text

    return ""

def main():
    key = input('搜索关键词:')
    page = int(input('查询页面:'))
    items = []
    print('当前搜索为 ' , key)
    count = 1
    for p_ in range(page):
        pp_ = p_ +  1            
        print('当前页面 : ',pp_)
        html = req_html(RUGE_SEARCH_URL.format(key,pp_))
        html_obj = bp4(html,"lxml")
        # 显示标题和链接
        articles = html_obj.find_all( name = 'article',attrs= {'class':"excerpt"})
        if(len(articles)< 1):
            exit()        

        for art_ in articles:
            item = {}
            item['title'] = art_.header.h2.a['title']
            item['url'] = art_.header.h2.a['href']
            items.append(item)
            print('{0:3} {1:40} {2}'.format(count,item['title'],item['url']))
            count += 1
    # 进行下载       
    PdfItems = []   
    c_ = 1  
    for d_ in items:
        print('当前下载',d_['title'],end = ' ')
        downurl = d_['url'].replace('.html','').replace('http://www.ifblue.net/','http://www.ifblue.net/download.html?pid=')
        # print(downurl)
        html = req_html(downurl)
        html_obj = bp4(html,"lxml")
        dd_ = html_obj.find('center')
        baiduurl = dd_.a['href']
        # 请求密码
        # print(dd_.a['href'])
        try:
            baidukey = req(baiduurl.replace('https://','').replace('http://','').replace('pan.baidu.com/s/1',''))
            # print(downurl)
            # print(dd_)
            # print(baiduurl)
            # print(baidukey)
            j_obj = json.loads(baidukey)
            PdfItem = {}
            PdfItem['id'] = c_
            PdfItem['title'] = d_['title']
            PdfItem['url'] = baiduurl
            PdfItem['code'] = j_obj['access_code']        
            PdfItems.append(PdfItem)
            print('{0} {1}'.format(baiduurl,j_obj['access_code']))
            c_ += 1
        except Exception as e:
            pass
            print(' 获取失败 ')

    # 进行下载
    # 将解析的保存到文件
    with open('down.txt','w')  as pf:
        for t_ in PdfItems:
            pf.write('{0:3} 名称: {1} 链接: {2} 密码: {3}\r\n'.format(t_['id'],t_['title'],t_['url'],t_['code']))

if __name__ == '__main__':
    main()

输出效果

当前下载 《读者文摘》pdf电子杂志下载—2018年2月刊 https://pan.baidu.com/s/1dSWVDW 28g6
当前下载 《读者文摘》pdf电子杂志下载—2018年1月刊 https://pan.baidu.com/s/1c3qtkXU hc8y
当前下载 《读者》pdf电子杂志下载—2018年2月上 https://pan.baidu.com/s/1kWCzsTx am9q
当前下载 《读者》原创版pdf电子杂志下载—2018年1月刊 https://pan.baidu.com/s/1ggp6g1t k3qm

  1 名称: 《读者》pdf电子杂志下载—2018年9月上 链接: https://pan.baidu.com/s/1wDgR2ER5gclOxmJuMX7mMw 密码: 4kkk
  2 名称: 《读者》pdf电子杂志下载—2018年8月下 链接: https://pan.baidu.com/s/1uzXDuaMGUIOty0m-DoAUEg 密码: b6c3
  3 名称: 《读者》pdf电子杂志下载—2018年8月上 链接: https://pan.baidu.com/s/1ED0eV-6IvmofjhLUoFN80Q 密码: 07k7
  4 名称: 《读者》pdf电子杂志下载—2018年7月下 链接: https://pan.baidu.com/s/1H3XIFCDdpgmfqWVh--L_6A 密码: nfwk
  5 名称: 《读者》pdf电子杂志下载—2018年7月上 链接: https://pan.baidu.com/s/1DfzSWdnhg-sYr-YZ0yl3HQ 密码: a5vg


免费评分

参与人数 2热心值 +2 收起 理由
笙若 + 1 谢谢@Thanks!
damide + 1 不懂程序,能不能做成软件呢

查看全部评分

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

Dirichlets 发表于 2018-9-26 17:34
在最新版Python 3.7.0上好像没法使用,特意去官网查了下,发现有可能是requests和beautifulsoup的兼容性问题
aerofsm 发表于 2018-9-26 12:59
cbkxh 发表于 2018-9-26 13:05
xiaowanzi52 发表于 2018-9-26 13:21
你为何不做成软件分享呢,不过也是感谢分享了呢 ,费心了呢
KevinHacker 发表于 2018-9-26 13:28
感觉直接搜索《读者》,一个个下载还快些
黄金体验 发表于 2018-9-26 13:43
感谢楼主分享~
rao1984 发表于 2018-9-26 14:00
感谢楼主分享~
abcd_ping 发表于 2018-9-26 14:26
有问题,同输出还有差距
damide 发表于 2018-9-26 14:43
小白如何使用呢
wuai_bin 发表于 2018-9-26 14:45
感谢分享!!!支持
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则 警告:本版块禁止灌水或回复与主题无关内容,违者重罚!

快速回复 收藏帖子 返回列表 搜索

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

GMT+8, 2024-5-18 03:55

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

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