mirror of
https://github.com/violettoolssite/CFspider.git
synced 2026-04-05 11:29:03 +08:00
c7880abf9e4b83a7ce7aff2fefe952e7f21c7def
CFspider
Cloudflare Workers 代理 IP 池,使用 Cloudflare 全球边缘节点 IP 作为代理出口。
在线演示
安装
pip install cfspider
使用
import cfspider
# 发送请求,使用 Cloudflare IP 出口
response = cfspider.get(
"https://httpbin.org/ip",
cf_proxies="https://ip.kami666.xyz"
)
print(response.text) # {"origin": "172.64.xxx.xxx"}
print(response.cf_colo) # NRT (节点代码)
使用 Session
import cfspider
# 创建 Session,只需设置一次
session = cfspider.Session(cf_proxies="https://ip.kami666.xyz")
# 之后无需再指定 cf_proxies
r1 = session.get("https://httpbin.org/ip")
r2 = session.get("https://example.com")
print(r1.text)
session.close()
部署 Workers
将 workers.js 代码复制到 Cloudflare Workers 即可部署你自己的代理节点。
License
MIT
Description
还在为爬虫和自动化项目的代理问题困扰吗?这个基于Cloudflare Workers的开源项目CFspider提供了一个新思路。它能让你利用Cloudflare遍布全球的边缘网络,轻松搭建起一个高效、免费的代理IP池,无缝兼容你熟悉的Python requests库和Playwright浏览器工具。如果你觉得这个方案有用,欢迎点击一个star⭐
Readme
Apache-2.0
14 MiB
Languages
JavaScript
35.5%
TypeScript
32.7%
Python
30.7%
CSS
1.1%