fromozu commited on
Commit
216f552
·
verified ·
1 Parent(s): 9d7a623

Upload hf_backend/test_md5_page.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. hf_backend/test_md5_page.py +77 -0
hf_backend/test_md5_page.py ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ 从 md5 页面提取文件信息,看看有没有其他下载方式
4
+ """
5
+
6
+ from playwright.sync_api import sync_playwright
7
+ import time
8
+ import re
9
+
10
+ MD5 = "d94c20d1364af9b484949659398c4062"
11
+ MD5_URL = f"https://annas-archive.gl/md5/{MD5}"
12
+
13
+ def get_md5_page_info():
14
+ """获取 md5 页面的所有信息"""
15
+ print(f"目标: {MD5_URL}\n")
16
+
17
+ with sync_playwright() as p:
18
+ browser = p.chromium.launch(headless=True)
19
+ context = browser.new_context(
20
+ user_agent="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36",
21
+ )
22
+ page = context.new_page()
23
+
24
+ print("访问 md5 页面...")
25
+ page.goto(MD5_URL, timeout=60000, wait_until="domcontentloaded")
26
+ page.wait_for_timeout(3000)
27
+
28
+ print(f"页面标题: {page.title()}")
29
+
30
+ # 获取所有文本内容
31
+ content = page.content()
32
+ print(f"HTML长度: {len(content)}")
33
+
34
+ # 查找所有链接
35
+ links = page.query_selector_all("a[href]")
36
+ print(f"找到 {len(links)} 个链接")
37
+
38
+ # 查找包含 epub 或 download 的链接
39
+ print("\n相关链接:")
40
+ for link in links:
41
+ href = link.get_attribute("href")
42
+ if href and any(k in href.lower() for k in ['epub', 'download', 'filepath', 'zlib', 'libgen']):
43
+ text = link.inner_text().strip()
44
+ print(f" {href[:80]} - {text[:30]}")
45
+
46
+ # 查找 JavaScript 中的数据
47
+ print("\n查找 JavaScript 中的文件信息...")
48
+ scripts = page.query_selector_all("script")
49
+ for script in scripts:
50
+ text = script.inner_text()
51
+ if 'filepath' in text or 'zlib' in text or 'no-category' in text:
52
+ print(f"找到相关脚本内容:")
53
+ # 提取相关部分
54
+ if 'filepath' in text:
55
+ filepath_match = re.search(r'filepath[=:]["\']([^"\']+)["\']', text)
56
+ if filepath_match:
57
+ print(f" filepath: {filepath_match.group(1)}")
58
+
59
+ # 获取可见文本
60
+ print("\n页面可见文本片段:")
61
+ try:
62
+ text = page.inner_text("body")
63
+ # 只打印相关部分
64
+ for line in text.split('\n'):
65
+ line = line.strip()
66
+ if line and any(k in line.lower() for k in ['epub', 'zlib', 'beckert', 'capitalism', 'download']):
67
+ print(f" {line[:100]}")
68
+ except:
69
+ pass
70
+
71
+ browser.close()
72
+
73
+ if __name__ == "__main__":
74
+ print("=" * 60)
75
+ print("获取 md5 页面信息")
76
+ print("=" * 60)
77
+ get_md5_page_info()