thordata-sdk 0.3.1__tar.gz → 1.0.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- thordata_sdk-1.0.0/LICENSE +21 -0
- thordata_sdk-1.0.0/PKG-INFO +208 -0
- thordata_sdk-1.0.0/README.md +165 -0
- thordata_sdk-1.0.0/pyproject.toml +136 -0
- {thordata_sdk-0.3.1 → thordata_sdk-1.0.0}/setup.cfg +4 -4
- thordata_sdk-1.0.0/src/thordata/__init__.py +151 -0
- thordata_sdk-1.0.0/src/thordata/_example_utils.py +76 -0
- thordata_sdk-1.0.0/src/thordata/_utils.py +187 -0
- thordata_sdk-1.0.0/src/thordata/async_client.py +1655 -0
- thordata_sdk-1.0.0/src/thordata/client.py +2012 -0
- thordata_sdk-1.0.0/src/thordata/demo.py +140 -0
- thordata_sdk-1.0.0/src/thordata/enums.py +384 -0
- thordata_sdk-1.0.0/src/thordata/exceptions.py +355 -0
- thordata_sdk-1.0.0/src/thordata/models.py +1184 -0
- thordata_sdk-1.0.0/src/thordata/retry.py +382 -0
- thordata_sdk-1.0.0/src/thordata_sdk.egg-info/PKG-INFO +208 -0
- thordata_sdk-1.0.0/src/thordata_sdk.egg-info/SOURCES.txt +29 -0
- thordata_sdk-1.0.0/src/thordata_sdk.egg-info/requires.txt +14 -0
- thordata_sdk-1.0.0/tests/test_async_client.py +83 -0
- thordata_sdk-1.0.0/tests/test_async_client_errors.py +109 -0
- thordata_sdk-1.0.0/tests/test_client.py +114 -0
- thordata_sdk-1.0.0/tests/test_client_errors.py +94 -0
- thordata_sdk-1.0.0/tests/test_enums.py +126 -0
- thordata_sdk-1.0.0/tests/test_examples.py +168 -0
- thordata_sdk-1.0.0/tests/test_exceptions.py +166 -0
- thordata_sdk-1.0.0/tests/test_models.py +326 -0
- thordata_sdk-1.0.0/tests/test_spec_parity.py +58 -0
- thordata_sdk-1.0.0/tests/test_task_status_and_wait.py +71 -0
- thordata_sdk-1.0.0/tests/test_user_agent.py +40 -0
- thordata_sdk-0.3.1/LICENSE +0 -201
- thordata_sdk-0.3.1/PKG-INFO +0 -200
- thordata_sdk-0.3.1/README.md +0 -171
- thordata_sdk-0.3.1/pyproject.toml +0 -42
- thordata_sdk-0.3.1/src/thordata/__init__.py +0 -16
- thordata_sdk-0.3.1/src/thordata/async_client.py +0 -281
- thordata_sdk-0.3.1/src/thordata/client.py +0 -486
- thordata_sdk-0.3.1/src/thordata/enums.py +0 -25
- thordata_sdk-0.3.1/src/thordata/parameters.py +0 -52
- thordata_sdk-0.3.1/src/thordata_sdk.egg-info/PKG-INFO +0 -200
- thordata_sdk-0.3.1/src/thordata_sdk.egg-info/SOURCES.txt +0 -15
- thordata_sdk-0.3.1/src/thordata_sdk.egg-info/requires.txt +0 -2
- thordata_sdk-0.3.1/tests/test_async_client.py +0 -59
- thordata_sdk-0.3.1/tests/test_client.py +0 -53
- {thordata_sdk-0.3.1 → thordata_sdk-1.0.0}/src/thordata_sdk.egg-info/dependency_links.txt +0 -0
- {thordata_sdk-0.3.1 → thordata_sdk-1.0.0}/src/thordata_sdk.egg-info/top_level.txt +0 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Thordata · AI Proxy & Web Data
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: thordata-sdk
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: The Official Python SDK for Thordata - AI Data Infrastructure & Proxy Network.
|
|
5
|
+
Author-email: Thordata Developer Team <support@thordata.com>
|
|
6
|
+
License: MIT
|
|
7
|
+
Project-URL: Homepage, https://www.thordata.com
|
|
8
|
+
Project-URL: Documentation, https://github.com/Thordata/thordata-python-sdk#readme
|
|
9
|
+
Project-URL: Source, https://github.com/Thordata/thordata-python-sdk
|
|
10
|
+
Project-URL: Tracker, https://github.com/Thordata/thordata-python-sdk/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/Thordata/thordata-python-sdk/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: web scraping,proxy,residential proxy,datacenter proxy,ai,llm,data-mining,serp,thordata,web scraper,anti-bot bypass
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
16
|
+
Classifier: Topic :: Internet :: WWW/HTTP
|
|
17
|
+
Classifier: Topic :: Internet :: Proxy Servers
|
|
18
|
+
Classifier: Programming Language :: Python :: 3
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
23
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
24
|
+
Classifier: Operating System :: OS Independent
|
|
25
|
+
Classifier: Typing :: Typed
|
|
26
|
+
Requires-Python: >=3.9
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
License-File: LICENSE
|
|
29
|
+
Requires-Dist: requests>=2.25.0
|
|
30
|
+
Requires-Dist: aiohttp>=3.9.0
|
|
31
|
+
Provides-Extra: dev
|
|
32
|
+
Requires-Dist: pytest>=7.0.0; extra == "dev"
|
|
33
|
+
Requires-Dist: pytest-asyncio>=0.21.0; extra == "dev"
|
|
34
|
+
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
|
|
35
|
+
Requires-Dist: pytest-httpserver>=1.0.0; extra == "dev"
|
|
36
|
+
Requires-Dist: python-dotenv>=1.0.0; extra == "dev"
|
|
37
|
+
Requires-Dist: black>=23.0.0; extra == "dev"
|
|
38
|
+
Requires-Dist: ruff>=0.1.0; extra == "dev"
|
|
39
|
+
Requires-Dist: mypy>=1.0.0; extra == "dev"
|
|
40
|
+
Requires-Dist: types-requests>=2.28.0; extra == "dev"
|
|
41
|
+
Requires-Dist: aioresponses>=0.7.6; extra == "dev"
|
|
42
|
+
Dynamic: license-file
|
|
43
|
+
|
|
44
|
+
# Thordata Python SDK
|
|
45
|
+
|
|
46
|
+
<div align="center">
|
|
47
|
+
|
|
48
|
+
**Official Python client for Thordata's Proxy Network, SERP API, Web Unlocker, and Web Scraper API.**
|
|
49
|
+
|
|
50
|
+
*Async-ready, type-safe, built for AI agents and large-scale data collection.*
|
|
51
|
+
|
|
52
|
+
[](https://pypi.org/project/thordata-sdk/)
|
|
53
|
+
[](https://python.org)
|
|
54
|
+
[](LICENSE)
|
|
55
|
+
|
|
56
|
+
[Documentation](https://doc.thordata.com) • [Dashboard](https://www.thordata.com) • [Examples](examples/)
|
|
57
|
+
|
|
58
|
+
</div>
|
|
59
|
+
|
|
60
|
+
---
|
|
61
|
+
|
|
62
|
+
## ✨ Features
|
|
63
|
+
|
|
64
|
+
- 🌐 **Proxy Network**: Residential, Mobile, Datacenter, ISP proxies with geo-targeting
|
|
65
|
+
- 🔍 **SERP API**: Google, Bing, Yandex, DuckDuckGo search results
|
|
66
|
+
- 🔓 **Web Unlocker**: Bypass Cloudflare, CAPTCHAs, anti-bot systems
|
|
67
|
+
- 🕷️ **Web Scraper API**: Async task-based scraping (Text & Video/Audio)
|
|
68
|
+
- 📊 **Account Management**: Usage stats, sub-users, IP whitelist
|
|
69
|
+
- ⚡ **Async Support**: Full async/await support with aiohttp
|
|
70
|
+
- 🔄 **Auto Retry**: Configurable retry with exponential backoff
|
|
71
|
+
|
|
72
|
+
---
|
|
73
|
+
|
|
74
|
+
## 📦 Installation
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
pip install thordata-sdk
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
---
|
|
81
|
+
|
|
82
|
+
## 🔐 Configuration
|
|
83
|
+
|
|
84
|
+
Set environment variables:
|
|
85
|
+
|
|
86
|
+
```bash
|
|
87
|
+
# Required for Scraper APIs (SERP, Universal, Tasks)
|
|
88
|
+
export THORDATA_SCRAPER_TOKEN=your_token
|
|
89
|
+
|
|
90
|
+
# Public/Location APIs (Dashboard -> My account -> API)
|
|
91
|
+
export THORDATA_PUBLIC_TOKEN=your_public_token
|
|
92
|
+
export THORDATA_PUBLIC_KEY=your_public_key
|
|
93
|
+
|
|
94
|
+
```
|
|
95
|
+
|
|
96
|
+
---
|
|
97
|
+
|
|
98
|
+
## 🚀 Quick Start
|
|
99
|
+
|
|
100
|
+
```python
|
|
101
|
+
from thordata import ThordataClient, Engine
|
|
102
|
+
|
|
103
|
+
# Initialize (reads from env vars)
|
|
104
|
+
client = ThordataClient(
|
|
105
|
+
scraper_token="your_token",
|
|
106
|
+
public_token="pub_token",
|
|
107
|
+
public_key="pub_key"
|
|
108
|
+
)
|
|
109
|
+
|
|
110
|
+
# SERP Search
|
|
111
|
+
results = client.serp_search("python tutorial", engine=Engine.GOOGLE)
|
|
112
|
+
print(f"Found {len(results.get('organic', []))} results")
|
|
113
|
+
|
|
114
|
+
# Universal Scrape
|
|
115
|
+
html = client.universal_scrape("https://httpbin.org/html")
|
|
116
|
+
print(html[:100])
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
---
|
|
120
|
+
|
|
121
|
+
## 📖 Feature Guide
|
|
122
|
+
|
|
123
|
+
### SERP API
|
|
124
|
+
|
|
125
|
+
```python
|
|
126
|
+
from thordata import SerpRequest
|
|
127
|
+
|
|
128
|
+
# Advanced search
|
|
129
|
+
results = client.serp_search_advanced(SerpRequest(
|
|
130
|
+
query="pizza",
|
|
131
|
+
engine="google_local",
|
|
132
|
+
country="us",
|
|
133
|
+
location="New York",
|
|
134
|
+
num=10
|
|
135
|
+
))
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### Web Scraper API (Async Tasks)
|
|
139
|
+
|
|
140
|
+
**Create Task:**
|
|
141
|
+
```python
|
|
142
|
+
task_id = client.create_scraper_task(
|
|
143
|
+
file_name="my_task",
|
|
144
|
+
spider_id="universal",
|
|
145
|
+
spider_name="universal",
|
|
146
|
+
parameters={"url": "https://example.com"}
|
|
147
|
+
)
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
**Video Download (New):**
|
|
151
|
+
```python
|
|
152
|
+
from thordata import CommonSettings
|
|
153
|
+
|
|
154
|
+
task_id = client.create_video_task(
|
|
155
|
+
file_name="{{VideoID}}",
|
|
156
|
+
spider_id="youtube_video_by-url",
|
|
157
|
+
spider_name="youtube.com",
|
|
158
|
+
parameters={"url": "https://youtube.com/watch?v=..."},
|
|
159
|
+
common_settings=CommonSettings(resolution="1080p")
|
|
160
|
+
)
|
|
161
|
+
```
|
|
162
|
+
|
|
163
|
+
**Wait & Download:**
|
|
164
|
+
```python
|
|
165
|
+
status = client.wait_for_task(task_id)
|
|
166
|
+
if status == "ready":
|
|
167
|
+
url = client.get_task_result(task_id)
|
|
168
|
+
print(url)
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
### Account Management
|
|
172
|
+
|
|
173
|
+
```python
|
|
174
|
+
# Usage Statistics
|
|
175
|
+
stats = client.get_usage_statistics("2024-01-01", "2024-01-31")
|
|
176
|
+
print(f"Balance: {stats.balance_gb():.2f} GB")
|
|
177
|
+
|
|
178
|
+
# Proxy Users
|
|
179
|
+
users = client.list_proxy_users()
|
|
180
|
+
print(f"Sub-users: {users.user_count}")
|
|
181
|
+
|
|
182
|
+
# Whitelist IP
|
|
183
|
+
client.add_whitelist_ip("1.2.3.4")
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
### Proxy Network
|
|
187
|
+
|
|
188
|
+
```python
|
|
189
|
+
from thordata import ProxyConfig
|
|
190
|
+
|
|
191
|
+
# Generate Proxy URL
|
|
192
|
+
proxy_url = client.build_proxy_url(
|
|
193
|
+
username="proxy_user",
|
|
194
|
+
password="proxy_pass",
|
|
195
|
+
country="us",
|
|
196
|
+
city="ny"
|
|
197
|
+
)
|
|
198
|
+
|
|
199
|
+
# Use with requests
|
|
200
|
+
import requests
|
|
201
|
+
requests.get("https://httpbin.org/ip", proxies={"http": proxy_url, "https": proxy_url})
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
---
|
|
205
|
+
|
|
206
|
+
## 📄 License
|
|
207
|
+
|
|
208
|
+
MIT License
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
# Thordata Python SDK
|
|
2
|
+
|
|
3
|
+
<div align="center">
|
|
4
|
+
|
|
5
|
+
**Official Python client for Thordata's Proxy Network, SERP API, Web Unlocker, and Web Scraper API.**
|
|
6
|
+
|
|
7
|
+
*Async-ready, type-safe, built for AI agents and large-scale data collection.*
|
|
8
|
+
|
|
9
|
+
[](https://pypi.org/project/thordata-sdk/)
|
|
10
|
+
[](https://python.org)
|
|
11
|
+
[](LICENSE)
|
|
12
|
+
|
|
13
|
+
[Documentation](https://doc.thordata.com) • [Dashboard](https://www.thordata.com) • [Examples](examples/)
|
|
14
|
+
|
|
15
|
+
</div>
|
|
16
|
+
|
|
17
|
+
---
|
|
18
|
+
|
|
19
|
+
## ✨ Features
|
|
20
|
+
|
|
21
|
+
- 🌐 **Proxy Network**: Residential, Mobile, Datacenter, ISP proxies with geo-targeting
|
|
22
|
+
- 🔍 **SERP API**: Google, Bing, Yandex, DuckDuckGo search results
|
|
23
|
+
- 🔓 **Web Unlocker**: Bypass Cloudflare, CAPTCHAs, anti-bot systems
|
|
24
|
+
- 🕷️ **Web Scraper API**: Async task-based scraping (Text & Video/Audio)
|
|
25
|
+
- 📊 **Account Management**: Usage stats, sub-users, IP whitelist
|
|
26
|
+
- ⚡ **Async Support**: Full async/await support with aiohttp
|
|
27
|
+
- 🔄 **Auto Retry**: Configurable retry with exponential backoff
|
|
28
|
+
|
|
29
|
+
---
|
|
30
|
+
|
|
31
|
+
## 📦 Installation
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
pip install thordata-sdk
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
---
|
|
38
|
+
|
|
39
|
+
## 🔐 Configuration
|
|
40
|
+
|
|
41
|
+
Set environment variables:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
# Required for Scraper APIs (SERP, Universal, Tasks)
|
|
45
|
+
export THORDATA_SCRAPER_TOKEN=your_token
|
|
46
|
+
|
|
47
|
+
# Public/Location APIs (Dashboard -> My account -> API)
|
|
48
|
+
export THORDATA_PUBLIC_TOKEN=your_public_token
|
|
49
|
+
export THORDATA_PUBLIC_KEY=your_public_key
|
|
50
|
+
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## 🚀 Quick Start
|
|
56
|
+
|
|
57
|
+
```python
|
|
58
|
+
from thordata import ThordataClient, Engine
|
|
59
|
+
|
|
60
|
+
# Initialize (reads from env vars)
|
|
61
|
+
client = ThordataClient(
|
|
62
|
+
scraper_token="your_token",
|
|
63
|
+
public_token="pub_token",
|
|
64
|
+
public_key="pub_key"
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
# SERP Search
|
|
68
|
+
results = client.serp_search("python tutorial", engine=Engine.GOOGLE)
|
|
69
|
+
print(f"Found {len(results.get('organic', []))} results")
|
|
70
|
+
|
|
71
|
+
# Universal Scrape
|
|
72
|
+
html = client.universal_scrape("https://httpbin.org/html")
|
|
73
|
+
print(html[:100])
|
|
74
|
+
```
|
|
75
|
+
|
|
76
|
+
---
|
|
77
|
+
|
|
78
|
+
## 📖 Feature Guide
|
|
79
|
+
|
|
80
|
+
### SERP API
|
|
81
|
+
|
|
82
|
+
```python
|
|
83
|
+
from thordata import SerpRequest
|
|
84
|
+
|
|
85
|
+
# Advanced search
|
|
86
|
+
results = client.serp_search_advanced(SerpRequest(
|
|
87
|
+
query="pizza",
|
|
88
|
+
engine="google_local",
|
|
89
|
+
country="us",
|
|
90
|
+
location="New York",
|
|
91
|
+
num=10
|
|
92
|
+
))
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
### Web Scraper API (Async Tasks)
|
|
96
|
+
|
|
97
|
+
**Create Task:**
|
|
98
|
+
```python
|
|
99
|
+
task_id = client.create_scraper_task(
|
|
100
|
+
file_name="my_task",
|
|
101
|
+
spider_id="universal",
|
|
102
|
+
spider_name="universal",
|
|
103
|
+
parameters={"url": "https://example.com"}
|
|
104
|
+
)
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
**Video Download (New):**
|
|
108
|
+
```python
|
|
109
|
+
from thordata import CommonSettings
|
|
110
|
+
|
|
111
|
+
task_id = client.create_video_task(
|
|
112
|
+
file_name="{{VideoID}}",
|
|
113
|
+
spider_id="youtube_video_by-url",
|
|
114
|
+
spider_name="youtube.com",
|
|
115
|
+
parameters={"url": "https://youtube.com/watch?v=..."},
|
|
116
|
+
common_settings=CommonSettings(resolution="1080p")
|
|
117
|
+
)
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Wait & Download:**
|
|
121
|
+
```python
|
|
122
|
+
status = client.wait_for_task(task_id)
|
|
123
|
+
if status == "ready":
|
|
124
|
+
url = client.get_task_result(task_id)
|
|
125
|
+
print(url)
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
### Account Management
|
|
129
|
+
|
|
130
|
+
```python
|
|
131
|
+
# Usage Statistics
|
|
132
|
+
stats = client.get_usage_statistics("2024-01-01", "2024-01-31")
|
|
133
|
+
print(f"Balance: {stats.balance_gb():.2f} GB")
|
|
134
|
+
|
|
135
|
+
# Proxy Users
|
|
136
|
+
users = client.list_proxy_users()
|
|
137
|
+
print(f"Sub-users: {users.user_count}")
|
|
138
|
+
|
|
139
|
+
# Whitelist IP
|
|
140
|
+
client.add_whitelist_ip("1.2.3.4")
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Proxy Network
|
|
144
|
+
|
|
145
|
+
```python
|
|
146
|
+
from thordata import ProxyConfig
|
|
147
|
+
|
|
148
|
+
# Generate Proxy URL
|
|
149
|
+
proxy_url = client.build_proxy_url(
|
|
150
|
+
username="proxy_user",
|
|
151
|
+
password="proxy_pass",
|
|
152
|
+
country="us",
|
|
153
|
+
city="ny"
|
|
154
|
+
)
|
|
155
|
+
|
|
156
|
+
# Use with requests
|
|
157
|
+
import requests
|
|
158
|
+
requests.get("https://httpbin.org/ip", proxies={"http": proxy_url, "https": proxy_url})
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
---
|
|
162
|
+
|
|
163
|
+
## 📄 License
|
|
164
|
+
|
|
165
|
+
MIT License
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61.0", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "thordata-sdk"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "The Official Python SDK for Thordata - AI Data Infrastructure & Proxy Network."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
requires-python = ">=3.9"
|
|
11
|
+
license = {text = "MIT"}
|
|
12
|
+
authors = [
|
|
13
|
+
{name = "Thordata Developer Team", email = "support@thordata.com"}
|
|
14
|
+
]
|
|
15
|
+
keywords = [
|
|
16
|
+
"web scraping",
|
|
17
|
+
"proxy",
|
|
18
|
+
"residential proxy",
|
|
19
|
+
"datacenter proxy",
|
|
20
|
+
"ai",
|
|
21
|
+
"llm",
|
|
22
|
+
"data-mining",
|
|
23
|
+
"serp",
|
|
24
|
+
"thordata",
|
|
25
|
+
"web scraper",
|
|
26
|
+
"anti-bot bypass"
|
|
27
|
+
]
|
|
28
|
+
classifiers = [
|
|
29
|
+
"Development Status :: 4 - Beta",
|
|
30
|
+
"Intended Audience :: Developers",
|
|
31
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
32
|
+
"Topic :: Internet :: WWW/HTTP",
|
|
33
|
+
"Topic :: Internet :: Proxy Servers",
|
|
34
|
+
"Programming Language :: Python :: 3",
|
|
35
|
+
"Programming Language :: Python :: 3.9",
|
|
36
|
+
"Programming Language :: Python :: 3.10",
|
|
37
|
+
"Programming Language :: Python :: 3.11",
|
|
38
|
+
"Programming Language :: Python :: 3.12",
|
|
39
|
+
"License :: OSI Approved :: MIT License",
|
|
40
|
+
"Operating System :: OS Independent",
|
|
41
|
+
"Typing :: Typed",
|
|
42
|
+
]
|
|
43
|
+
|
|
44
|
+
dependencies = [
|
|
45
|
+
"requests>=2.25.0",
|
|
46
|
+
"aiohttp>=3.9.0",
|
|
47
|
+
]
|
|
48
|
+
|
|
49
|
+
[project.optional-dependencies]
|
|
50
|
+
dev = [
|
|
51
|
+
"pytest>=7.0.0",
|
|
52
|
+
"pytest-asyncio>=0.21.0",
|
|
53
|
+
"pytest-cov>=4.0.0",
|
|
54
|
+
"pytest-httpserver>=1.0.0",
|
|
55
|
+
"python-dotenv>=1.0.0",
|
|
56
|
+
"black>=23.0.0",
|
|
57
|
+
"ruff>=0.1.0",
|
|
58
|
+
"mypy>=1.0.0",
|
|
59
|
+
"types-requests>=2.28.0",
|
|
60
|
+
"aioresponses>=0.7.6",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
[project.urls]
|
|
64
|
+
"Homepage" = "https://www.thordata.com"
|
|
65
|
+
"Documentation" = "https://github.com/Thordata/thordata-python-sdk#readme"
|
|
66
|
+
"Source" = "https://github.com/Thordata/thordata-python-sdk"
|
|
67
|
+
"Tracker" = "https://github.com/Thordata/thordata-python-sdk/issues"
|
|
68
|
+
"Changelog" = "https://github.com/Thordata/thordata-python-sdk/blob/main/CHANGELOG.md"
|
|
69
|
+
|
|
70
|
+
# Setuptools setup
|
|
71
|
+
[tool.setuptools.packages.find]
|
|
72
|
+
where = ["src"]
|
|
73
|
+
|
|
74
|
+
[tool.setuptools.package-data]
|
|
75
|
+
thordata = ["py.typed"]
|
|
76
|
+
|
|
77
|
+
[tool.black]
|
|
78
|
+
line-length = 88
|
|
79
|
+
target-version = ['py39', 'py310', 'py311', 'py312']
|
|
80
|
+
include = '\.pyi?$'
|
|
81
|
+
|
|
82
|
+
[tool.ruff]
|
|
83
|
+
line-length = 88
|
|
84
|
+
target-version = "py39"
|
|
85
|
+
|
|
86
|
+
[tool.ruff.lint]
|
|
87
|
+
select = [
|
|
88
|
+
"E", # pycodestyle errors
|
|
89
|
+
"W", # pycodestyle warnings
|
|
90
|
+
"F", # pyflakes
|
|
91
|
+
"I", # isort (import sorting)
|
|
92
|
+
"B", # flake8-bugbear
|
|
93
|
+
]
|
|
94
|
+
ignore = [
|
|
95
|
+
"E501", # line too long (handled by black)
|
|
96
|
+
"E731", # do not assign a lambda expression
|
|
97
|
+
"F401", # imported but unused (we have some intentional re-exports)
|
|
98
|
+
]
|
|
99
|
+
|
|
100
|
+
[tool.ruff.lint.isort]
|
|
101
|
+
known-first-party = ["thordata"]
|
|
102
|
+
|
|
103
|
+
# Mypy
|
|
104
|
+
[tool.mypy]
|
|
105
|
+
python_version = "3.9"
|
|
106
|
+
warn_return_any = false
|
|
107
|
+
warn_unused_ignores = false
|
|
108
|
+
disallow_untyped_defs = false
|
|
109
|
+
disallow_incomplete_defs = false
|
|
110
|
+
check_untyped_defs = false
|
|
111
|
+
strict_optional = false
|
|
112
|
+
show_error_codes = true
|
|
113
|
+
ignore_missing_imports = true
|
|
114
|
+
|
|
115
|
+
[[tool.mypy.overrides]]
|
|
116
|
+
module = ["aiohttp.*", "requests.*"]
|
|
117
|
+
ignore_missing_imports = true
|
|
118
|
+
|
|
119
|
+
# Pytest setup
|
|
120
|
+
[tool.pytest.ini_options]
|
|
121
|
+
testpaths = ["tests"]
|
|
122
|
+
asyncio_mode = "auto"
|
|
123
|
+
addopts = "-v --cov=thordata --cov-report=term-missing"
|
|
124
|
+
|
|
125
|
+
# Coverage setup
|
|
126
|
+
[tool.coverage.run]
|
|
127
|
+
source = ["src/thordata"]
|
|
128
|
+
branch = true
|
|
129
|
+
|
|
130
|
+
[tool.coverage.report]
|
|
131
|
+
exclude_lines = [
|
|
132
|
+
"pragma: no cover",
|
|
133
|
+
"def __repr__",
|
|
134
|
+
"raise NotImplementedError",
|
|
135
|
+
"if TYPE_CHECKING:",
|
|
136
|
+
]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
[egg_info]
|
|
2
|
-
tag_build =
|
|
3
|
-
tag_date = 0
|
|
4
|
-
|
|
1
|
+
[egg_info]
|
|
2
|
+
tag_build =
|
|
3
|
+
tag_date = 0
|
|
4
|
+
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Thordata Python SDK
|
|
3
|
+
|
|
4
|
+
Official Python client for Thordata's Proxy Network, SERP API,
|
|
5
|
+
Universal Scraping API (Web Unlocker), and Web Scraper API.
|
|
6
|
+
|
|
7
|
+
Basic Usage:
|
|
8
|
+
>>> from thordata import ThordataClient
|
|
9
|
+
>>>
|
|
10
|
+
>>> client = ThordataClient(
|
|
11
|
+
... scraper_token="your_token",
|
|
12
|
+
... public_token="your_public_token",
|
|
13
|
+
... public_key="your_public_key"
|
|
14
|
+
... )
|
|
15
|
+
>>>
|
|
16
|
+
>>> # Proxy request
|
|
17
|
+
>>> response = client.get("https://httpbin.org/ip")
|
|
18
|
+
>>>
|
|
19
|
+
>>> # SERP search
|
|
20
|
+
>>> results = client.serp_search("python tutorial", engine="google")
|
|
21
|
+
>>>
|
|
22
|
+
>>> # Universal scrape
|
|
23
|
+
>>> html = client.universal_scrape("https://example.com", js_render=True)
|
|
24
|
+
|
|
25
|
+
Async Usage:
|
|
26
|
+
>>> from thordata import AsyncThordataClient
|
|
27
|
+
>>> import asyncio
|
|
28
|
+
>>>
|
|
29
|
+
>>> async def main():
|
|
30
|
+
... async with AsyncThordataClient(
|
|
31
|
+
... scraper_token="your_token"
|
|
32
|
+
... ) as client:
|
|
33
|
+
... response = await client.get("https://httpbin.org/ip")
|
|
34
|
+
>>>
|
|
35
|
+
>>> asyncio.run(main())
|
|
36
|
+
"""
|
|
37
|
+
|
|
38
|
+
__version__ = "1.0.0"
|
|
39
|
+
__author__ = "Thordata Developer Team"
|
|
40
|
+
__email__ = "support@thordata.com"
|
|
41
|
+
|
|
42
|
+
# Main clients
|
|
43
|
+
from .async_client import AsyncThordataClient
|
|
44
|
+
from .client import ThordataClient
|
|
45
|
+
|
|
46
|
+
# Enums
|
|
47
|
+
from .enums import (
|
|
48
|
+
BingSearchType,
|
|
49
|
+
Continent,
|
|
50
|
+
Country,
|
|
51
|
+
DataFormat,
|
|
52
|
+
Device,
|
|
53
|
+
Engine,
|
|
54
|
+
GoogleSearchType,
|
|
55
|
+
GoogleTbm,
|
|
56
|
+
OutputFormat,
|
|
57
|
+
ProxyHost,
|
|
58
|
+
ProxyPort,
|
|
59
|
+
ProxyType,
|
|
60
|
+
SessionType,
|
|
61
|
+
TaskStatus,
|
|
62
|
+
TimeRange,
|
|
63
|
+
)
|
|
64
|
+
|
|
65
|
+
# Exceptions
|
|
66
|
+
from .exceptions import (
|
|
67
|
+
ThordataAPIError,
|
|
68
|
+
ThordataAuthError,
|
|
69
|
+
ThordataConfigError,
|
|
70
|
+
ThordataError,
|
|
71
|
+
ThordataNetworkError,
|
|
72
|
+
ThordataNotCollectedError,
|
|
73
|
+
ThordataRateLimitError,
|
|
74
|
+
ThordataServerError,
|
|
75
|
+
ThordataTimeoutError,
|
|
76
|
+
ThordataValidationError,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
# Models
|
|
80
|
+
from .models import (
|
|
81
|
+
CommonSettings,
|
|
82
|
+
ProxyConfig,
|
|
83
|
+
ProxyProduct,
|
|
84
|
+
ProxyServer,
|
|
85
|
+
ProxyUser,
|
|
86
|
+
ProxyUserList,
|
|
87
|
+
ScraperTaskConfig,
|
|
88
|
+
SerpRequest,
|
|
89
|
+
StaticISPProxy,
|
|
90
|
+
StickySession,
|
|
91
|
+
TaskStatusResponse,
|
|
92
|
+
UniversalScrapeRequest,
|
|
93
|
+
UsageStatistics,
|
|
94
|
+
VideoTaskConfig,
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
# Retry utilities
|
|
98
|
+
from .retry import RetryConfig
|
|
99
|
+
|
|
100
|
+
# Public API
|
|
101
|
+
__all__ = [
|
|
102
|
+
# Version
|
|
103
|
+
"__version__",
|
|
104
|
+
# Clients
|
|
105
|
+
"ThordataClient",
|
|
106
|
+
"AsyncThordataClient",
|
|
107
|
+
# Enums
|
|
108
|
+
"Engine",
|
|
109
|
+
"GoogleSearchType",
|
|
110
|
+
"BingSearchType",
|
|
111
|
+
"ProxyType",
|
|
112
|
+
"SessionType",
|
|
113
|
+
"Continent",
|
|
114
|
+
"Country",
|
|
115
|
+
"OutputFormat",
|
|
116
|
+
"DataFormat",
|
|
117
|
+
"TaskStatus",
|
|
118
|
+
"Device",
|
|
119
|
+
"TimeRange",
|
|
120
|
+
"ProxyHost",
|
|
121
|
+
"ProxyPort",
|
|
122
|
+
"GoogleTbm",
|
|
123
|
+
# Models
|
|
124
|
+
"ProxyConfig",
|
|
125
|
+
"ProxyProduct",
|
|
126
|
+
"ProxyServer",
|
|
127
|
+
"ProxyUser",
|
|
128
|
+
"ProxyUserList",
|
|
129
|
+
"UsageStatistics",
|
|
130
|
+
"StaticISPProxy",
|
|
131
|
+
"StickySession",
|
|
132
|
+
"SerpRequest",
|
|
133
|
+
"UniversalScrapeRequest",
|
|
134
|
+
"ScraperTaskConfig",
|
|
135
|
+
"CommonSettings",
|
|
136
|
+
"VideoTaskConfig",
|
|
137
|
+
"TaskStatusResponse",
|
|
138
|
+
# Exceptions
|
|
139
|
+
"ThordataError",
|
|
140
|
+
"ThordataConfigError",
|
|
141
|
+
"ThordataNetworkError",
|
|
142
|
+
"ThordataTimeoutError",
|
|
143
|
+
"ThordataAPIError",
|
|
144
|
+
"ThordataAuthError",
|
|
145
|
+
"ThordataRateLimitError",
|
|
146
|
+
"ThordataServerError",
|
|
147
|
+
"ThordataValidationError",
|
|
148
|
+
"ThordataNotCollectedError",
|
|
149
|
+
# Retry
|
|
150
|
+
"RetryConfig",
|
|
151
|
+
]
|