dataify-sdk 1.1.0__tar.gz → 1.3.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.
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/.gitignore +7 -1
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/PKG-INFO +32 -4
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/README.md +60 -32
- dataify_sdk-1.3.0/docs/AI_WEB.md +189 -0
- dataify_sdk-1.3.0/examples/ai_web.py +48 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/pyproject.toml +2 -2
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/__init__.py +27 -2
- dataify_sdk-1.3.0/src/dataify_sdk/ai_web.py +417 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/client.py +250 -197
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/errors.py +21 -1
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/__init__.py +3 -0
- dataify_sdk-1.3.0/src/dataify_sdk/tools/chatgptanswer.py +66 -0
- dataify_sdk-1.3.0/tests/test_client/test_ai_web.py +251 -0
- dataify_sdk-1.3.0/tests/test_errors.py +43 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/tests/test_tools/test_tool_modules.py +41 -13
- dataify_sdk-1.1.0/PYPI_RELEASE.md +0 -136
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/LICENSE +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/scripts/codegen.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/_codegen/__init__.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/_codegen/generate.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/airbnbproduct.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/amazoncomment.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/amazonglobalproduct.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/amazonproduct.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/amazonproductlist.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/amazonseller.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/bingimages.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/bingmaps.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/bingnews.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/bingsearch.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/bingshopping.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/bingvideos.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/bookinghotellist.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/crunchbasecompany.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/duckduckgosearch.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/ebayinfo.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/facebookcomment.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/facebookevent.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/facebookpost.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/facebookprofile.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/githubrepository.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/glassdoorcompany.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/glassdoorjoblistings.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googleaimode.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googlefinance.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googleflights.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googlehotels.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googleimages.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googlejobs.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googlelens.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googlelocal.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googlemapcomment.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googlemapdetails.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googlemaps.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googlenews.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googlepatents.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googleplay.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googleplaystoreinformation.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googleplaystorereviews.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googlescholar.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googlesearch.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googleshopping.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googleshoppinginfo.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googletrends.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/googlevideos.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/indeedcompaniesinfo.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/indeedjoblistings.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/instagramcomment.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/instagramprofiles.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/instagramreel.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/linkedincompanyinformation.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/linkedinjoblistingsinformation.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/redditcomment.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/redditposts.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/tiktokcomment.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/tiktokposts.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/tiktokprofiles.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/tiktokshop.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/twitterpost.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/twitterprofile.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/walmartproduct.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/yandexsearch.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/youtubeaudio.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/youtubecomment.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/youtubeproduct.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/youtubeprofiles.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/youtubetranscript.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/youtubevideo.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/youtubevideopost.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/src/dataify_sdk/tools/zillowproduct.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/tests/__init__.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/tests/conftest.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/tests/test_client/__init__.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/tests/test_client/test_http_client.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/tests/test_tools/__init__.py +0 -0
- {dataify_sdk-1.1.0 → dataify_sdk-1.3.0}/tests/test_tools/test_codegen.py +0 -0
|
@@ -3,9 +3,14 @@ __pycache__/
|
|
|
3
3
|
*.py[cod]
|
|
4
4
|
*.egg-info/
|
|
5
5
|
dist/
|
|
6
|
+
dist-test/
|
|
6
7
|
build/
|
|
7
8
|
*.egg
|
|
8
9
|
|
|
10
|
+
# Environment / secrets
|
|
11
|
+
.env
|
|
12
|
+
.env.*
|
|
13
|
+
|
|
9
14
|
# Virtual environments
|
|
10
15
|
.venv/
|
|
11
16
|
venv/
|
|
@@ -24,7 +29,8 @@ htmlcov/
|
|
|
24
29
|
# Mypy
|
|
25
30
|
.mypy_cache/
|
|
26
31
|
.workbuddy/
|
|
27
|
-
docs
|
|
32
|
+
docs/*
|
|
33
|
+
!docs/AI_WEB.md
|
|
28
34
|
# OS
|
|
29
35
|
.DS_Store
|
|
30
36
|
Thumbs.db
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: dataify-sdk
|
|
3
|
-
Version: 1.
|
|
4
|
-
Summary: Python SDK that calls the Dataify upstream REST API directly (no MCP layer)
|
|
3
|
+
Version: 1.3.0
|
|
4
|
+
Summary: Python SDK that calls the Dataify upstream REST API directly (no MCP layer) for web scrapers and search engines.
|
|
5
5
|
Project-URL: Homepage, https://dashboard.dataify.com
|
|
6
6
|
Project-URL: Repository, https://github.com/dataify/dataify-sdk
|
|
7
7
|
Author-email: Dataify <support@dataify.com>
|
|
@@ -32,7 +32,8 @@ Python 客户端库,**直接调用** [Dataify](https://dashboard.dataify.com)
|
|
|
32
32
|
|
|
33
33
|
- 🔍 **搜索引擎** — Google(17 种)、Bing(6 种)、Yandex、DuckDuckGo,走 `POST /request`
|
|
34
34
|
- 🛒 **平台抓取器** — Amazon、YouTube、TikTok、Facebook、Instagram、Reddit、Twitter/X、LinkedIn、Glassdoor、Indeed、Walmart、Zillow、Airbnb、Booking、Crunchbase、eBay、GitHub 等 45 个采集器,先走 `POST /builder?platform=1`,再可查询任务状态并下载结果
|
|
35
|
-
-
|
|
35
|
+
- 🌐 **AI Web** — 聚合搜索、站点发现、正文提取和结果下载,见 [docs/AI_WEB.md](https://github.com/dataify/dataify-sdk/blob/main/docs/AI_WEB.md)
|
|
36
|
+
- 📖 **参数全暴露** — 每个工具函数把上游请求参数、类型、是否必填、中文描述都写在签名与 docstring 里;离线参数手册由维护者通过 `scripts/codegen.py` 生成
|
|
36
37
|
- 🐍 **零依赖** — 仅用标准库 `urllib`,同步 API
|
|
37
38
|
|
|
38
39
|
## 安装
|
|
@@ -80,11 +81,38 @@ result = google_search(q="pizza")
|
|
|
80
81
|
|
|
81
82
|
`client.query_scraper_task_status(...)` 会返回任务状态 JSON,`data.status` 常见值为 `处理中`、`成功`、`失败`。任务成功后可用 `client.download_scraper_task_result(task_id, result_type="json")` 下载最终结果;`result_type` 支持 `json`、`csv`、`xlsx`。
|
|
82
83
|
|
|
84
|
+
## AI Web
|
|
85
|
+
|
|
86
|
+
AI Web 的搜索、站点发现和正文提取通过 `client.ai_web` 调用,默认使用正式域名 `https://aiwebapi.dataify.com`。测试或私有网关可通过 `AI_WEB_API_BASE_URL` 或 `ai_web_base_url` 覆盖。
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
from dataify_sdk import AI_WEB_UNIQUE_IDS, DataifyClient
|
|
90
|
+
|
|
91
|
+
client = DataifyClient() # 默认从 DATAIFY_API_TOKEN 读取 token
|
|
92
|
+
|
|
93
|
+
result = client.ai_web.search(
|
|
94
|
+
AI_WEB_UNIQUE_IDS.SEARCH_WEB,
|
|
95
|
+
"OpenAI",
|
|
96
|
+
max_results=3,
|
|
97
|
+
source="web",
|
|
98
|
+
)
|
|
99
|
+
print(result.request_id)
|
|
100
|
+
print(result.outputs)
|
|
101
|
+
|
|
102
|
+
page = client.ai_web.extract(
|
|
103
|
+
AI_WEB_UNIQUE_IDS.EXTRACT,
|
|
104
|
+
"https://example.com/article",
|
|
105
|
+
formats=["markdown"],
|
|
106
|
+
)
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`search` 支持 `SEARCH_WEB`、`SEARCH_NEWS`、`SEARCH_SHOPPING`、`SEARCH_SCHOLAR` 四种模式。`search`、`map`、`extract` 返回 `AIWebResponse(request_id, outputs)`,其中 `outputs` 统一为数组;`execute` / `execute_raw` 支持动态 operation,`download_result` 通过 `request_id` 下载结果。完整参数和示例见 [`docs/AI_WEB.md`](https://github.com/dataify/dataify-sdk/blob/main/docs/AI_WEB.md)。
|
|
110
|
+
|
|
83
111
|
## API 设计
|
|
84
112
|
|
|
85
113
|
- **每个 `spider_id` = 一个独立函数**(采集类),例如 `amazon_product_by_asin()`、`amazon_product_by_url()`、`amazon_product_by_keywords()`。
|
|
86
114
|
- **搜索类每个引擎一个函数**,例如 `google_search()`、`bing_search()`、`yandex_search()`。
|
|
87
|
-
- 所有函数签名与 docstring
|
|
115
|
+
- 所有函数签名与 docstring 完整暴露上游参数及其描述;离线参数手册由维护者通过 `scripts/codegen.py` 生成。
|
|
88
116
|
- 函数返回解析后的 JSON `dict`(即上游原始响应)。
|
|
89
117
|
|
|
90
118
|
## 错误处理
|
|
@@ -6,8 +6,9 @@ Python 客户端库,**直接调用** [Dataify](https://dashboard.dataify.com)
|
|
|
6
6
|
## 功能
|
|
7
7
|
|
|
8
8
|
- 🔍 **搜索引擎** — Google(17 种)、Bing(6 种)、Yandex、DuckDuckGo,走 `POST /request`
|
|
9
|
-
- 🛒 **平台抓取器** — Amazon、YouTube、TikTok、Facebook、Instagram、Reddit、Twitter/X、LinkedIn、Glassdoor、Indeed、Walmart、Zillow、Airbnb、Booking、Crunchbase、eBay、GitHub 等 45 个采集器,先走 `POST /builder?platform=1`,再可查询任务状态并下载结果
|
|
10
|
-
-
|
|
9
|
+
- 🛒 **平台抓取器** — Amazon、YouTube、TikTok、Facebook、Instagram、Reddit、Twitter/X、LinkedIn、Glassdoor、Indeed、Walmart、Zillow、Airbnb、Booking、Crunchbase、eBay、GitHub 等 45 个采集器,先走 `POST /builder?platform=1`,再可查询任务状态并下载结果
|
|
10
|
+
- 🌐 **AI Web** — 聚合搜索、站点发现、正文提取和结果下载,见 [docs/AI_WEB.md](https://github.com/dataify/dataify-sdk/blob/main/docs/AI_WEB.md)
|
|
11
|
+
- 📖 **参数全暴露** — 每个工具函数把上游请求参数、类型、是否必填、中文描述都写在签名与 docstring 里;离线参数手册由维护者通过 `scripts/codegen.py` 生成
|
|
11
12
|
- 🐍 **零依赖** — 仅用标准库 `urllib`,同步 API
|
|
12
13
|
|
|
13
14
|
## 安装
|
|
@@ -25,41 +26,68 @@ from dataify_sdk import DataifyClient
|
|
|
25
26
|
from dataify_sdk.tools.amazonproduct import amazon_product_by_asin
|
|
26
27
|
from dataify_sdk.tools.googlesearch import google_search
|
|
27
28
|
|
|
28
|
-
# token 也可通过环境变量 DATAIFY_API_TOKEN 提供(兼容旧版 DATAIFY_TOKEN)
|
|
29
|
-
client = DataifyClient(token="YOUR_TOKEN")
|
|
30
|
-
|
|
31
|
-
# 采集类:先提交 Builder 任务
|
|
32
|
-
task = amazon_product_by_asin(asin="B0BZYCJK89", client=client)
|
|
33
|
-
task_id = task["data"]["task_id"]
|
|
34
|
-
|
|
35
|
-
# 再查询任务状态
|
|
36
|
-
status = client.query_scraper_task_status(task_id)
|
|
37
|
-
if status["data"]["status"] == "成功":
|
|
38
|
-
result = client.download_scraper_task_result(task_id, result_type="json")
|
|
39
|
-
|
|
40
|
-
# 搜索类:直接打搜索引擎接口
|
|
41
|
-
result = google_search(q="pizza", client=client)
|
|
42
|
-
```
|
|
43
|
-
|
|
44
|
-
也可以不传 `client`,使用默认 client(优先读取 `DATAIFY_API_TOKEN`,兼容 `DATAIFY_TOKEN`):
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
export DATAIFY_API_TOKEN="..."
|
|
48
|
-
```
|
|
49
|
-
|
|
50
|
-
```python
|
|
51
|
-
from dataify_sdk.tools.googlesearch import google_search
|
|
52
|
-
|
|
53
|
-
result = google_search(q="pizza")
|
|
54
|
-
```
|
|
55
|
-
|
|
56
|
-
`client.query_scraper_task_status(...)` 会返回任务状态 JSON,`data.status` 常见值为 `处理中`、`成功`、`失败`。任务成功后可用 `client.download_scraper_task_result(task_id, result_type="json")` 下载最终结果;`result_type` 支持 `json`、`csv`、`xlsx`。
|
|
29
|
+
# token 也可通过环境变量 DATAIFY_API_TOKEN 提供(兼容旧版 DATAIFY_TOKEN)
|
|
30
|
+
client = DataifyClient(token="YOUR_TOKEN")
|
|
31
|
+
|
|
32
|
+
# 采集类:先提交 Builder 任务
|
|
33
|
+
task = amazon_product_by_asin(asin="B0BZYCJK89", client=client)
|
|
34
|
+
task_id = task["data"]["task_id"]
|
|
35
|
+
|
|
36
|
+
# 再查询任务状态
|
|
37
|
+
status = client.query_scraper_task_status(task_id)
|
|
38
|
+
if status["data"]["status"] == "成功":
|
|
39
|
+
result = client.download_scraper_task_result(task_id, result_type="json")
|
|
40
|
+
|
|
41
|
+
# 搜索类:直接打搜索引擎接口
|
|
42
|
+
result = google_search(q="pizza", client=client)
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
也可以不传 `client`,使用默认 client(优先读取 `DATAIFY_API_TOKEN`,兼容 `DATAIFY_TOKEN`):
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
export DATAIFY_API_TOKEN="..."
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
```python
|
|
52
|
+
from dataify_sdk.tools.googlesearch import google_search
|
|
53
|
+
|
|
54
|
+
result = google_search(q="pizza")
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
`client.query_scraper_task_status(...)` 会返回任务状态 JSON,`data.status` 常见值为 `处理中`、`成功`、`失败`。任务成功后可用 `client.download_scraper_task_result(task_id, result_type="json")` 下载最终结果;`result_type` 支持 `json`、`csv`、`xlsx`。
|
|
58
|
+
|
|
59
|
+
## AI Web
|
|
60
|
+
|
|
61
|
+
AI Web 的搜索、站点发现和正文提取通过 `client.ai_web` 调用,默认使用正式域名 `https://aiwebapi.dataify.com`。测试或私有网关可通过 `AI_WEB_API_BASE_URL` 或 `ai_web_base_url` 覆盖。
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
from dataify_sdk import AI_WEB_UNIQUE_IDS, DataifyClient
|
|
65
|
+
|
|
66
|
+
client = DataifyClient() # 默认从 DATAIFY_API_TOKEN 读取 token
|
|
67
|
+
|
|
68
|
+
result = client.ai_web.search(
|
|
69
|
+
AI_WEB_UNIQUE_IDS.SEARCH_WEB,
|
|
70
|
+
"OpenAI",
|
|
71
|
+
max_results=3,
|
|
72
|
+
source="web",
|
|
73
|
+
)
|
|
74
|
+
print(result.request_id)
|
|
75
|
+
print(result.outputs)
|
|
76
|
+
|
|
77
|
+
page = client.ai_web.extract(
|
|
78
|
+
AI_WEB_UNIQUE_IDS.EXTRACT,
|
|
79
|
+
"https://example.com/article",
|
|
80
|
+
formats=["markdown"],
|
|
81
|
+
)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
`search` 支持 `SEARCH_WEB`、`SEARCH_NEWS`、`SEARCH_SHOPPING`、`SEARCH_SCHOLAR` 四种模式。`search`、`map`、`extract` 返回 `AIWebResponse(request_id, outputs)`,其中 `outputs` 统一为数组;`execute` / `execute_raw` 支持动态 operation,`download_result` 通过 `request_id` 下载结果。完整参数和示例见 [`docs/AI_WEB.md`](https://github.com/dataify/dataify-sdk/blob/main/docs/AI_WEB.md)。
|
|
57
85
|
|
|
58
86
|
## API 设计
|
|
59
87
|
|
|
60
88
|
- **每个 `spider_id` = 一个独立函数**(采集类),例如 `amazon_product_by_asin()`、`amazon_product_by_url()`、`amazon_product_by_keywords()`。
|
|
61
89
|
- **搜索类每个引擎一个函数**,例如 `google_search()`、`bing_search()`、`yandex_search()`。
|
|
62
|
-
- 所有函数签名与 docstring
|
|
90
|
+
- 所有函数签名与 docstring 完整暴露上游参数及其描述;离线参数手册由维护者通过 `scripts/codegen.py` 生成。
|
|
63
91
|
- 函数返回解析后的 JSON `dict`(即上游原始响应)。
|
|
64
92
|
|
|
65
93
|
## 错误处理
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# AI Web API
|
|
2
|
+
|
|
3
|
+
`client.ai_web` 调用 AI Web 的搜索、站点发现、正文提取和结果下载接口。所有请求使用 Dataify Bearer Token;网关返回 JSON 响应体,`X-Request-Id` 响应头会暴露为 `response.request_id`。
|
|
4
|
+
|
|
5
|
+
## 配置网关
|
|
6
|
+
|
|
7
|
+
AI Web 默认使用正式域名 `https://aiwebapi.dataify.com`,不需要额外配置:
|
|
8
|
+
|
|
9
|
+
```python
|
|
10
|
+
from dataify_sdk import DataifyClient
|
|
11
|
+
|
|
12
|
+
client = DataifyClient() # token 从 DATAIFY_API_TOKEN 读取
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
`ai_web_base_url` 只填域名(不要带 `/search`、`/map` 或 `/extract`),SDK 会自动拼接接口路径。测试或私有网关可通过 `AI_WEB_API_BASE_URL` 或 `ai_web_base_url` 覆盖:
|
|
16
|
+
|
|
17
|
+
```python
|
|
18
|
+
import os
|
|
19
|
+
|
|
20
|
+
from dataify_sdk import DataifyClient
|
|
21
|
+
|
|
22
|
+
client = DataifyClient(
|
|
23
|
+
token=os.environ["DATAIFY_API_TOKEN"],
|
|
24
|
+
ai_web_base_url="https://your-test-gateway.example.com",
|
|
25
|
+
)
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
显式把客户端基址清空时仍会抛出 `DataifyMissingAIWebBaseUrlError`。
|
|
29
|
+
|
|
30
|
+
## 基本用法
|
|
31
|
+
|
|
32
|
+
```python
|
|
33
|
+
from dataify_sdk import AI_WEB_UNIQUE_IDS, DataifyClient
|
|
34
|
+
|
|
35
|
+
client = DataifyClient() # token 从 DATAIFY_API_TOKEN 读取
|
|
36
|
+
|
|
37
|
+
result = client.ai_web.search(
|
|
38
|
+
AI_WEB_UNIQUE_IDS.SEARCH_WEB,
|
|
39
|
+
"OpenAI",
|
|
40
|
+
max_results=3,
|
|
41
|
+
source="web",
|
|
42
|
+
)
|
|
43
|
+
|
|
44
|
+
print(result.request_id)
|
|
45
|
+
print(result.outputs)
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
`AI_WEB_UNIQUE_IDS` 提供当前网关的固定标识:`SEARCH_WEB`、`SEARCH_SHOPPING`、`SEARCH_NEWS`、`SEARCH_SCHOLAR`、`MAP`、`EXTRACT`;同时提供 TS 风格的小写别名(如 `search_news`)。
|
|
49
|
+
|
|
50
|
+
## 方法
|
|
51
|
+
|
|
52
|
+
| SDK 方法 | 上游接口 | 说明 |
|
|
53
|
+
| --- | --- | --- |
|
|
54
|
+
| `client.ai_web.search(...)` | `POST /search` | 聚合 web、news、shopping、scholar 搜索,可选择提取结果正文 |
|
|
55
|
+
| `client.ai_web.map(...)` | `POST /map` | 发现站点页面 URL、标题和描述 |
|
|
56
|
+
| `client.ai_web.extract(...)` | `POST /extract` | 提取 markdown、原始 HTML、清洗后 HTML 或链接 |
|
|
57
|
+
| `client.ai_web.execute(operation, params)` | `POST /search`、`/map`、`/extract` | 按名称动态调用,并把 `outputs` 统一成数组 |
|
|
58
|
+
| `client.ai_web.execute_raw(operation, params)` | 同上 | 保留上游原始 `outputs` 结构 |
|
|
59
|
+
| `client.ai_web.download_result(task_id)` | `POST /download` | 通过 `request_id`(即 `task_id`)下载服务端保留的结果 |
|
|
60
|
+
|
|
61
|
+
便捷方法返回 `AIWebResponse`:
|
|
62
|
+
|
|
63
|
+
```python
|
|
64
|
+
@dataclass(frozen=True)
|
|
65
|
+
class AIWebResponse:
|
|
66
|
+
request_id: str | None
|
|
67
|
+
outputs: Any
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
`search`、`map`、`extract`、`execute` 会统一 `outputs`:
|
|
71
|
+
|
|
72
|
+
- `None` -> `[]`
|
|
73
|
+
- JSON 数组 -> 保持数组
|
|
74
|
+
- 单个对象或基本类型 -> 包装成单元素数组
|
|
75
|
+
|
|
76
|
+
需要上游原始结构时使用 `execute_raw`。
|
|
77
|
+
|
|
78
|
+
## Search
|
|
79
|
+
|
|
80
|
+
```python
|
|
81
|
+
result = client.ai_web.search(
|
|
82
|
+
AI_WEB_UNIQUE_IDS.SEARCH_WEB,
|
|
83
|
+
"OpenAI",
|
|
84
|
+
max_results=10,
|
|
85
|
+
source="web", # web | news | shopping | scholar
|
|
86
|
+
country="US",
|
|
87
|
+
language="en",
|
|
88
|
+
time_range="week", # web/news 支持;shopping/scholar 不支持
|
|
89
|
+
extract_content=True,
|
|
90
|
+
extract_options={
|
|
91
|
+
"formats": ["markdown"],
|
|
92
|
+
"only_main_content": True,
|
|
93
|
+
"advanced_mode": True,
|
|
94
|
+
},
|
|
95
|
+
)
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
`time_range` 仅网页搜索和新闻搜索支持;shopping 和 scholar 不支持。`extract_options.formats` 支持 `markdown`、`raw_html`、`clean_html`、`links`。`search` 的 `extract_options` 仅在 `extract_content=True` 时生效。
|
|
99
|
+
|
|
100
|
+
## Map
|
|
101
|
+
|
|
102
|
+
```python
|
|
103
|
+
result = client.ai_web.map(
|
|
104
|
+
AI_WEB_UNIQUE_IDS.MAP,
|
|
105
|
+
"https://docs.example.com",
|
|
106
|
+
country="US",
|
|
107
|
+
domain_filter="all", # domain | all
|
|
108
|
+
limit=100,
|
|
109
|
+
sitemap="include", # skip | include | only
|
|
110
|
+
)
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Extract
|
|
114
|
+
|
|
115
|
+
```python
|
|
116
|
+
result = client.ai_web.extract(
|
|
117
|
+
AI_WEB_UNIQUE_IDS.EXTRACT,
|
|
118
|
+
"https://example.com/article",
|
|
119
|
+
formats=["markdown", "links"],
|
|
120
|
+
only_main_content=True,
|
|
121
|
+
headers={"User-Agent": "Dataify SDK"},
|
|
122
|
+
timeout_ms=60_000,
|
|
123
|
+
advanced_mode=True,
|
|
124
|
+
)
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
`formats` 缺省或传空数组时表示不抓取正文。`headers` 是传给目标网站的请求头,不能包含 `Host` 或 hop-by-hop headers。
|
|
128
|
+
|
|
129
|
+
## 动态 operation
|
|
130
|
+
|
|
131
|
+
```python
|
|
132
|
+
result = client.ai_web.execute(
|
|
133
|
+
"extract",
|
|
134
|
+
{
|
|
135
|
+
"unique_id": AI_WEB_UNIQUE_IDS.EXTRACT,
|
|
136
|
+
"url": "https://example.com",
|
|
137
|
+
"formats": ["markdown"],
|
|
138
|
+
},
|
|
139
|
+
)
|
|
140
|
+
|
|
141
|
+
raw = client.ai_web.execute_raw(
|
|
142
|
+
"extract",
|
|
143
|
+
{
|
|
144
|
+
"unique_id": AI_WEB_UNIQUE_IDS.EXTRACT,
|
|
145
|
+
"url": "https://example.com",
|
|
146
|
+
"formats": ["markdown"],
|
|
147
|
+
},
|
|
148
|
+
)
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
`execute` 会把 `outputs` 统一成数组;`execute_raw` 保留网关返回的原始 JSON 结构。
|
|
152
|
+
|
|
153
|
+
## 下载结果
|
|
154
|
+
|
|
155
|
+
保留 `request_id`,在服务端保留期内下载结果:
|
|
156
|
+
|
|
157
|
+
```python
|
|
158
|
+
result = client.ai_web.extract(
|
|
159
|
+
AI_WEB_UNIQUE_IDS.EXTRACT,
|
|
160
|
+
"https://example.com/article",
|
|
161
|
+
formats=["markdown"],
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
if result.request_id:
|
|
165
|
+
downloaded = client.ai_web.download_result(result.request_id)
|
|
166
|
+
print(downloaded)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
`download_result` 发送 `POST /download`,JSON 请求体为 `{"task_id": "<request_id>"}`,使用 Bearer 认证,不会在请求体里重复放置 API key。
|
|
170
|
+
|
|
171
|
+
## 错误处理
|
|
172
|
+
|
|
173
|
+
- 未配置网关:抛出 `DataifyMissingAIWebBaseUrlError`,请求不会发出。
|
|
174
|
+
- 上游返回非 2xx:抛出 `DataifyAPIError`,包含 `status_code` 和 `body`。
|
|
175
|
+
- 缺少 `unique_id`、`query` 或 `url`:抛出 `ValueError`。
|
|
176
|
+
- `formats` 非法或重复:抛出 `ValueError`。
|
|
177
|
+
|
|
178
|
+
```python
|
|
179
|
+
from dataify_sdk import DataifyAPIError, DataifyClient, DataifyMissingAIWebBaseUrlError
|
|
180
|
+
|
|
181
|
+
client = DataifyClient()
|
|
182
|
+
|
|
183
|
+
try:
|
|
184
|
+
result = client.ai_web.search("search_news", "OpenAI")
|
|
185
|
+
except DataifyMissingAIWebBaseUrlError:
|
|
186
|
+
print("AI Web 网关不可用")
|
|
187
|
+
except DataifyAPIError as exc:
|
|
188
|
+
print(f"AI Web 返回错误 HTTP {exc.status_code}: {exc.body}")
|
|
189
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"""AI Web search, map, extract, and download example.
|
|
2
|
+
|
|
3
|
+
Set ``DATAIFY_API_TOKEN`` before running. AI Web defaults to
|
|
4
|
+
``https://aiwebapi.dataify.com``; set ``AI_WEB_API_BASE_URL`` only to override it:
|
|
5
|
+
|
|
6
|
+
python examples/ai_web.py
|
|
7
|
+
"""
|
|
8
|
+
|
|
9
|
+
from __future__ import annotations
|
|
10
|
+
|
|
11
|
+
import os
|
|
12
|
+
|
|
13
|
+
from dataify_sdk import AI_WEB_UNIQUE_IDS, DataifyClient
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
def main() -> None:
|
|
17
|
+
client = DataifyClient(token=os.environ.get("DATAIFY_API_TOKEN"))
|
|
18
|
+
query = os.environ.get("DATAIFY_TEST_QUERY", "OpenAI")
|
|
19
|
+
url = os.environ.get("DATAIFY_TEST_URL", "https://example.com")
|
|
20
|
+
|
|
21
|
+
search = client.ai_web.search(
|
|
22
|
+
AI_WEB_UNIQUE_IDS.SEARCH_WEB,
|
|
23
|
+
query,
|
|
24
|
+
max_results=3,
|
|
25
|
+
source="web",
|
|
26
|
+
)
|
|
27
|
+
print("search request_id:", search.request_id)
|
|
28
|
+
print("search outputs:", search.outputs)
|
|
29
|
+
|
|
30
|
+
mapping = client.ai_web.map(AI_WEB_UNIQUE_IDS.MAP, url, limit=10)
|
|
31
|
+
print("map request_id:", mapping.request_id)
|
|
32
|
+
print("map outputs:", mapping.outputs)
|
|
33
|
+
|
|
34
|
+
extract = client.ai_web.extract(
|
|
35
|
+
AI_WEB_UNIQUE_IDS.EXTRACT,
|
|
36
|
+
url,
|
|
37
|
+
formats=["markdown"],
|
|
38
|
+
)
|
|
39
|
+
print("extract request_id:", extract.request_id)
|
|
40
|
+
print("extract outputs:", extract.outputs)
|
|
41
|
+
|
|
42
|
+
if extract.request_id:
|
|
43
|
+
downloaded = client.ai_web.download_result(extract.request_id)
|
|
44
|
+
print("downloaded:", downloaded)
|
|
45
|
+
|
|
46
|
+
|
|
47
|
+
if __name__ == "__main__":
|
|
48
|
+
main()
|
|
@@ -4,8 +4,8 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "dataify-sdk"
|
|
7
|
-
version = "1.
|
|
8
|
-
description = "Python SDK that calls the Dataify upstream REST API directly (no MCP layer)
|
|
7
|
+
version = "1.3.0"
|
|
8
|
+
description = "Python SDK that calls the Dataify upstream REST API directly (no MCP layer) for web scrapers and search engines."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = {text = "MIT"}
|
|
11
11
|
requires-python = ">=3.10"
|
|
@@ -23,15 +23,30 @@ or, using the default client (token from ``DATAIFY_API_TOKEN``, with
|
|
|
23
23
|
|
|
24
24
|
from __future__ import annotations
|
|
25
25
|
|
|
26
|
-
from dataify_sdk.
|
|
26
|
+
from dataify_sdk.ai_web import (
|
|
27
|
+
AI_WEB_FORMATS,
|
|
28
|
+
AI_WEB_UNIQUE_IDS,
|
|
29
|
+
AIWebFormats,
|
|
30
|
+
AIWebOperation,
|
|
31
|
+
AIWebResponse,
|
|
32
|
+
AIWebService,
|
|
33
|
+
AIWebUniqueIds,
|
|
34
|
+
normalize_ai_web_outputs,
|
|
35
|
+
)
|
|
36
|
+
from dataify_sdk.client import (
|
|
37
|
+
DEFAULT_AI_WEB_BASE_URL,
|
|
38
|
+
DataifyClient,
|
|
39
|
+
get_default_client,
|
|
40
|
+
)
|
|
27
41
|
from dataify_sdk.errors import (
|
|
28
42
|
DataifyAPIError,
|
|
29
43
|
DataifyConnectionError,
|
|
30
44
|
DataifyError,
|
|
45
|
+
DataifyMissingAIWebBaseUrlError,
|
|
31
46
|
DataifyTimeoutError,
|
|
32
47
|
)
|
|
33
48
|
|
|
34
|
-
__version__ = "1.
|
|
49
|
+
__version__ = "1.3.0"
|
|
35
50
|
|
|
36
51
|
|
|
37
52
|
|
|
@@ -40,8 +55,18 @@ __all__ = [
|
|
|
40
55
|
"__version__",
|
|
41
56
|
"DataifyClient",
|
|
42
57
|
"get_default_client",
|
|
58
|
+
"DEFAULT_AI_WEB_BASE_URL",
|
|
43
59
|
"DataifyError",
|
|
44
60
|
"DataifyAPIError",
|
|
45
61
|
"DataifyConnectionError",
|
|
46
62
|
"DataifyTimeoutError",
|
|
63
|
+
"DataifyMissingAIWebBaseUrlError",
|
|
64
|
+
"AIWebService",
|
|
65
|
+
"AIWebResponse",
|
|
66
|
+
"AIWebOperation",
|
|
67
|
+
"AIWebUniqueIds",
|
|
68
|
+
"AIWebFormats",
|
|
69
|
+
"AI_WEB_UNIQUE_IDS",
|
|
70
|
+
"AI_WEB_FORMATS",
|
|
71
|
+
"normalize_ai_web_outputs",
|
|
47
72
|
]
|