atad-tokyo commited on
Commit
a847403
·
verified ·
1 Parent(s): 2cb414d

Upload download_terabox.py with huggingface_hub

Browse files
Files changed (1) hide show
  1. download_terabox.py +91 -0
download_terabox.py ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python
2
+ """
3
+ 下载 Terabox 分享链接的脚本
4
+ """
5
+ import requests
6
+ import re
7
+ import json
8
+ from urllib.parse import urlparse, parse_qs
9
+
10
+ def download_terabox(share_url):
11
+ """
12
+ 下载 Terabox 分享链接
13
+ """
14
+ headers = {
15
+ 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36',
16
+ 'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
17
+ 'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8',
18
+ 'Referer': 'https://www.1024terabox.com/',
19
+ }
20
+
21
+ session = requests.Session()
22
+ session.headers.update(headers)
23
+
24
+ print(f"正在访问分享链接: {share_url}")
25
+
26
+ try:
27
+ # 访问分享链接
28
+ response = session.get(share_url, allow_redirects=True, timeout=30)
29
+ print(f"状态码: {response.status_code}")
30
+ print(f"最终URL: {response.url}")
31
+
32
+ # 检查是否需要验证
33
+ if 'need verify' in response.text.lower() or '验证' in response.text:
34
+ print("⚠️ 该链接需要验证,可能需要手动访问或使用浏览器下载")
35
+ print(f"请访问: {response.url}")
36
+ return False
37
+
38
+ # 尝试提取下载链接
39
+ # Terabox 通常使用 JavaScript 加载真实下载链接
40
+ # 这里尝试几种常见的方法
41
+
42
+ # 方法1: 查找 API 调用
43
+ api_patterns = [
44
+ r'api\.1024tera\.com[^"\']+',
45
+ r'download[^"\']+',
46
+ r'file[^"\']+download[^"\']+',
47
+ ]
48
+
49
+ for pattern in api_patterns:
50
+ matches = re.findall(pattern, response.text)
51
+ if matches:
52
+ print(f"找到可能的下载链接: {matches[0]}")
53
+
54
+ # 方法2: 查找文件信息
55
+ file_info_patterns = [
56
+ r'"file_name"[^:]+:\s*"([^"]+)"',
57
+ r'"file_size"[^:]+:\s*(\d+)',
58
+ ]
59
+
60
+ file_info = {}
61
+ for pattern in file_info_patterns:
62
+ matches = re.findall(pattern, response.text)
63
+ if matches:
64
+ if 'file_name' in pattern:
65
+ file_info['name'] = matches[0]
66
+ elif 'file_size' in pattern:
67
+ file_info['size'] = matches[0]
68
+
69
+ if file_info:
70
+ print(f"文件信息: {file_info}")
71
+
72
+ # 保存页面内容以便分析
73
+ with open('/data/cxk/terabox_page.html', 'w', encoding='utf-8') as f:
74
+ f.write(response.text)
75
+ print("页面内容已保存到: /data/cxk/terabox_page.html")
76
+
77
+ print("\n提示: Terabox 链接通常需要:")
78
+ print("1. 使用浏览器访问并手动下载")
79
+ print("2. 或使用专门的工具如 terabox-downloader")
80
+ print("3. 或安装浏览器自动化工具 (selenium)")
81
+
82
+ return False
83
+
84
+ except Exception as e:
85
+ print(f"❌ 下载失败: {e}")
86
+ return False
87
+
88
+ if __name__ == "__main__":
89
+ share_url = "https://1024terabox.com/s/1AE7uAU3Ib8aRBSyF1TMpow"
90
+ download_terabox(share_url)
91
+