v1.8.0: 添加数据提取和批量请求功能

新增功能:
- extract.py: CSS/XPath/JSONPath 数据提取
- export.py: JSON/CSV/Excel/SQLite 导出
- batch.py: 批量请求、并发控制、进度条
- Response 集成 find/pick/save 方法
- CLI 添加 get/post/batch 命令
- 可选依赖组 [extract][xpath][excel][all]

更新文档和版本号
This commit is contained in:
test01
2026-01-08 23:14:52 +08:00
parent 9bd209b6de
commit 7ffe7b333f
13 changed files with 3191 additions and 92 deletions

46
test.py
View File

@@ -1,7 +1,43 @@
import cfspider
# 查看帮助信息
help(cfspider.get)
help(cfspider.Browser)
help(cfspider.StealthSession)
help(cfspider.mirror)
# ========== 方案一:使用有效的 Workers 地址 ==========
# 请将下面的地址替换为你的实际 Workers 地址
# Workers 地址格式https://your-worker-name.your-subdomain.workers.dev
WORKERS_URL = "https://proxy.kami666.xyz/" # 替换为你的 Workers 地址
TOKEN = "HAIfuge27" # 替换为你在 Workers 中配置的 token
try:
# 使用 Token 鉴权的请求
res = cfspider.get(
"https://httpbin.org/ip",
cf_proxies=WORKERS_URL,
token=TOKEN
)
print("✅ 请求成功!")
print(f"响应内容: {res.text}")
print(f"节点代码: {res.cf_colo}")
print(f"Ray ID: {res.cf_ray}")
print(f"状态码: {res.status_code}")
except Exception as e:
print(f"❌ 请求失败: {e}")
print("\n可能的原因:")
print("1. Workers 地址不正确或域名无法解析")
print("2. Token 配置错误")
print("3. 网络连接问题")
print("\n解决方案:")
print("1. 检查 Workers 地址是否正确")
print("2. 确认 Workers 已部署并运行")
print("3. 检查 Token 是否在 Workers 环境变量中配置")
print("4. 尝试不使用代理测试(见下方方案二)")
# ========== 方案二:不使用代理测试(用于验证库是否正常)==========
print("\n" + "="*50)
print("测试:不使用代理直接请求")
try:
res = cfspider.get("https://httpbin.org/ip")
print("✅ 直接请求成功!")
print(f"响应内容: {res.text}")
except Exception as e:
print(f"❌ 直接请求也失败: {e}")