若蓝阁 电子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