Community研究与数据分析github.com

brightdata/bright-data-best-practices

使用内置最佳实践构建生产级 Bright Data 集成。为开发者使用编码助手(如 Claude Code、Cursor 等)实现网络抓取、搜索、浏览器自动化和结构化数据提取提供参考文档。涵盖 Web Unlocker API、SERP API、Web Scraper API 和 Browser API(Scraping Browser)。

bright-data-best-practices 是什么?

该技能为开发者使用 AI 编码助手(如 Claude Code、Cursor 等)集成 Bright Data 平台提供了全面且生产就绪的最佳实践指南。它覆盖了 Bright Data 的核心 API,包括 Web Unlocker API(用于绕过反爬机制)、SERP API(用于搜索引擎结果页面抓取)、Web Scraper API(用于结构化数据提取)以及 Browser API(即 Scraping Browser,用于浏览器自动化)。技能文档以 SKILL.md 形式呈现,包含详细的代码示例、配置指南和调试技巧,确保集成过程高效且符合行业标准。此技能特别适合需要快速实现可靠网络数据提取的团队,帮助避免常见陷阱,并利用 Bright Data 的代理基础设施保证高成功率。

兼容平台✓Claude Code~Codex CLI✓Cursor
npx skills add https://github.com/brightdata/skills/tree/main/skills/bright-data-best-practices

Installed? Explore more 研究与数据分析 skills: affaan-m/uspto-database, affaan-m/scholar-evaluation, affaan-m/literature-review · View all 6 →

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

bright-data-best-practices 是做什么的?

使用内置最佳实践构建生产级 Bright Data 集成。为开发者使用编码助手(如 Claude Code、Cursor 等)实现网络抓取、搜索、浏览器自动化和结构化数据提取提供参考文档。涵盖 Web Unlocker API、SERP API、Web Scraper API 和 Browser API(Scraping Browser)。

概述

本技能文档旨在帮助开发者通过 AI 编码助手高效集成 Bright Data 平台。它提供了代码示例、配置参数和错误处理策略,确保集成过程稳健且可维护。

支持的 API

Web Unlocker API

  • 自动处理 IP 轮换和浏览器指纹识别
  • 适用于高难度目标网站

SERP API

  • 从 Google、Bing 等搜索引擎获取实时搜索结果
  • 支持自定义查询参数

Web Scraper API

  • 提取结构化数据(如产品信息、价格)
  • 支持自定义选择器和分页

Browser API(Scraping Browser)

  • 通过 Puppeteer/Playwright 控制无头浏览器
  • 适用于 JavaScript 渲染页面和复杂交互

环境变量

在项目中设置以下环境变量以安全使用 Bright Data API:

export BRIGHTDATA_USERNAME="your_username"
export BRIGHTDATA_PASSWORD="your_password"
export BRIGHTDATA_ZONE="your_zone"

示例代码

使用 Web Unlocker 抓取单个页面

import requests

url = "https://example.com"
proxy = f"http://{BRIGHTDATA_USERNAME}:{BRIGHTDATA_PASSWORD}@zproxy.lum-superproxy.io:22225"

response = requests.get(url, proxies={"http": proxy, "https": proxy})
print(response.text)

使用 SERP API 获取搜索结果

import requests

params = {
    "source": "google",
    "query": "latest AI trends"
}
response = requests.get("https://api.brightdata.com/serp", params=params)
print(response.json())

最佳实践

  • 错误重试:对临时故障使用指数退避策略
  • 速率限制:遵守 API 配额,避免高频请求
  • 数据验证:检查返回数据的完整性
  • 安全性:永远不要将凭据硬编码到代码中

调试和故障排除

查看 Bright Data 官方文档的日志和状态代码:

贡献

欢迎通过 Pull Requests 提交修复或改进。确保所有示例代码经过测试并遵循最佳实践。

Individual skills in this repo

This repo contains 3 individual skills — each has its own dedicated page.

brightdata/brightdata-cli

Guide for using the Bright Data CLI (`brightdata` / `bdata`) to scrape websites, search the web, extract structured data from 40+ platforms, manage proxy zones, and check account budget. Use this skill whenever the user wants to scrape a URL, search Google/Bing/Yandex, extract data from Amazon/LinkedIn/Instagram/TikTok/YouTube/Reddit or any other platform, check their Bright Data balance or zones, or do anything involving web data collection from the terminal. Also trigger when the user mentions brightdata, bdata, web scraping CLI, SERP API, or wants to install Bright Data skills into their coding agent.

brightdata/scrape

Scrape web content as clean markdown/HTML/JSON via the Bright Data CLI (`bdata scrape`). Use when the user wants to fetch a page, extract content from a list of URLs, or crawl paginated listings. Hands off to `data-feeds` for supported platforms (Amazon, LinkedIn, TikTok, Instagram, YouTube, Reddit, etc.) and to `search` when URLs must be discovered first. Requires the Bright Data CLI; proactively guides install + login if missing.

brightdata/seo-audit

When the user wants to audit, review, or diagnose SEO issues on their site. Uses live web data via the Bright Data CLI for accurate detection of JS-injected schema, hreflang, canonicals, and live SERP-based ranking checks. Also use when the user mentions "SEO audit," "technical SEO," "why am I not ranking," "SEO issues," "on-page SEO," "meta tags review," "SEO health check," "my traffic dropped," "lost rankings," "not showing up in Google," "site isn't ranking," "Google update hit me," "page speed," "core web vitals," "crawl errors," or "indexing issues." Use this even if the user just says something vague like "my SEO is bad" or "help with SEO" — start with an audit. For building pages at scale to target keywords, see programmatic-seo. For implementing structured data, see schema-markup. For AI search optimization, see ai-seo.

相关技能