github / github/dotnet-codespaces

test_brightdata.py

未关闭
#71 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
主要语言
HTML
星标
245
派生
321
PR 合并指标
30 天内没有已合并 PR

描述

import requests

API_KEY = "2aeaa6b4-7ba5-4d9a-8b80-e31caea98888"

ZONE = "web_unlocker1"

url = "https://api.brightdata.com/request"
headers = {
"Authorization": f"Bearer {API_KEY}",
"Content-Type": "application/json",
}

payload = {
"zone": ZONE,
"url": "https://creative.apple.com",
"format": "raw",

# Optional: location targeting
"country": "us",
"city": "seattle",
# "asn": 12345, # if you know the ASN and it is enabled for your zone
}

try:
response = requests.post(url, json=payload, headers=headers, timeout=60)
response.raise_for_status()
result = response.json()

print("Status code from target site:", result.get("status_code"))
print("First 500 characters of page:")
print(result.get("body", "")[:500])

except Exception as e:
print("Error:", e)

贡献指南

打开贡献指南

调研方向

首先检查 test_brightdata.py 以及对 https://api.brightdata.com/request 的 requests.post 调用。该 issue 没有说明应更改什么,也没有说明应如何验证完成情况,因此请在编辑之前确认预期行为。

由索引模型根据 Issue 内容生成。

评估

技术栈
python
领域
api, backend
Issue 类型
功能
难度
5/5
预计耗时
一周以上
活跃度
冷清
描述清晰度
需要澄清
新手友好度
20/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。