Spaces:
Running
Running
rogerxavier
commited on
Commit
•
01f823f
1
Parent(s):
ad3fcbc
Upload 3 files
Browse files- app.py +19 -0
- requirements.txt +3 -0
- utils.py +82 -0
app.py
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
from utils import *
|
3 |
+
import uvicorn
|
4 |
+
from fastapi import FastAPI
|
5 |
+
app = FastAPI()
|
6 |
+
|
7 |
+
|
8 |
+
# 通过fid来获取网盘信息->[] 链接+提取码 /None
|
9 |
+
@app.get("/getPanInfo")
|
10 |
+
def getPanInfo(fid:str):
|
11 |
+
session.headers = headers
|
12 |
+
jsonResp = try_puchase(fid=fid, session=session)
|
13 |
+
print(jsonResp)
|
14 |
+
panResult = get_pan_info(fid=fid, session=session) # 每次先尝试购买然后重新打开detail页面查询返回
|
15 |
+
print(panResult)
|
16 |
+
return panResult
|
17 |
+
|
18 |
+
if __name__ == '__main__':
|
19 |
+
uvicorn.run(app, host='0.0.0.0', port=7860)
|
requirements.txt
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
fastapi==0.111.0
|
2 |
+
uvicorn[standard]==0.17.*
|
3 |
+
|
utils.py
ADDED
@@ -0,0 +1,82 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# -*- coding: utf-8 -*-
|
2 |
+
import requests
|
3 |
+
|
4 |
+
from bs4 import BeautifulSoup
|
5 |
+
|
6 |
+
session = requests.Session()
|
7 |
+
#购买请求test
|
8 |
+
urlBase = 'https://jingling.bifangpu.com'
|
9 |
+
purchaseBase = urlBase+"/api/resource/purchase"
|
10 |
+
|
11 |
+
cookie = 'Hm_lvt_19198da8061c292cacd55088bd6e3eba=1718943605; _ga=GA1.2.1632565634.1718943606; _gid=GA1.2.1271774125.1718943606; jinglingpan:sessid=b3f56f88-841e-4b38-b1da-5d1f73c6f5fc; jinglingpan:sessid.sig=nCmvxKK90Ho6KRcluS0qWGIv1m0; Hm_lpvt_19198da8061c292cacd55088bd6e3eba=1718943640; _ga_Y024PNQKTV=GS1.2.1718943605.1.1.1718943640.0.0.0'
|
12 |
+
|
13 |
+
|
14 |
+
headers = {
|
15 |
+
"authority": "jingling.bifangpu.com",
|
16 |
+
"method": "GET",
|
17 |
+
"path": "/resource/detail/b01940f0f34e6ca91f68b258362d50f1",
|
18 |
+
"scheme": "https",
|
19 |
+
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
|
20 |
+
"Accept-Encoding": "gzip, deflate, br, zstd",
|
21 |
+
"Accept-Language": "zh-CN,zh;q=0.9",
|
22 |
+
"Cache-Control": "max-age=0",
|
23 |
+
"Cookie": cookie,
|
24 |
+
"Dnt": "1",
|
25 |
+
"If-None-Match": "\"5b56-ChT6C0U9s3iYKFMBV41XLcqXxRc\"",
|
26 |
+
"Priority": "u=0, i",
|
27 |
+
"Sec-Ch-Ua": "\"Not/A)Brand\";v=\"8\", \"Chromium\";v=\"126\", \"Google Chrome\";v=\"126\"",
|
28 |
+
"Sec-Ch-Ua-Mobile": "?0",
|
29 |
+
"Sec-Ch-Ua-Platform": "\"Windows\"",
|
30 |
+
"Sec-Fetch-Dest": "document",
|
31 |
+
"Sec-Fetch-Mode": "navigate",
|
32 |
+
"Sec-Fetch-Site": "same-origin",
|
33 |
+
"Sec-Fetch-User": "?1",
|
34 |
+
"Upgrade-Insecure-Requests": "1",
|
35 |
+
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
|
36 |
+
}
|
37 |
+
|
38 |
+
#返回{"code": 10602}说明已经购买过
|
39 |
+
def try_puchase(fid:str,session)->dict:
|
40 |
+
payload = {
|
41 |
+
"fid": fid
|
42 |
+
}
|
43 |
+
resp = session.post(purchaseBase, data=payload)
|
44 |
+
return resp.json()
|
45 |
+
|
46 |
+
#获取网盘信息函数,如果10602购买过,则刷新页面获取网盘信息,否则购买后刷新,反正都是调用一次try_purchase函数进行判断再刷新界面
|
47 |
+
#->list / None
|
48 |
+
def get_pan_info(fid:str,session):
|
49 |
+
#返回提取码和网盘连接的list
|
50 |
+
result = []
|
51 |
+
detailContent = get_detail(fid=fid, session=session)
|
52 |
+
|
53 |
+
soup = BeautifulSoup(detailContent, 'html.parser')
|
54 |
+
|
55 |
+
copy_contents = soup.find_all('span', class_='copy-content')
|
56 |
+
if copy_contents.__len__()>0:
|
57 |
+
for info in copy_contents:
|
58 |
+
#print(info.text) # 遍历得到提取码和网盘链接
|
59 |
+
result.append(info.text)
|
60 |
+
return result
|
61 |
+
return None
|
62 |
+
|
63 |
+
|
64 |
+
|
65 |
+
#通过fid刷新页面获取html返回信息函数
|
66 |
+
def get_detail(fid:str,session)->str:
|
67 |
+
detailUrl = urlBase+'/resource/detail/'+fid
|
68 |
+
resp = session.get(detailUrl)
|
69 |
+
return resp.text
|
70 |
+
|
71 |
+
|
72 |
+
|
73 |
+
if __name__ == '__main__':
|
74 |
+
fid = "b01940f0f34e6ca91f68b258362d50f1"
|
75 |
+
session.headers=headers
|
76 |
+
jsonResp = try_puchase(fid=fid,session=session)
|
77 |
+
print(jsonResp)
|
78 |
+
|
79 |
+
panResult = get_pan_info(fid = fid,session=session)#每次先尝试购买然后重新打开detail页面查询返回
|
80 |
+
print(panResult)
|
81 |
+
|
82 |
+
|