Documentation Index
Fetch the complete documentation index at: https://docs.brightdata.com/llms.txt
Use this file to discover all available pages before exploring further.
Pica 是一个平台,旨在增强 AI 代理的工作流,通过提供可靠、匿名且可扩展的网络访问,实现真实数据的自动化。将 Pica 与 Bright Data 集成,可以让 AI 代理利用 Bright Data 的高级网页抓取和代理网络能力,高效地收集和处理网络数据。
可用的 Bright Data 工具
Bright Data 为与 Pica 的集成提供以下工具:
- Scrapers:使用 Bright Data 强大的 Scrapers 自动化网页数据提取。
- Unlocker API:访问并获取采用高级反爬虫措施的网站数据。
如何将 Bright Data 与 Pica 集成
安装 Bright Data 集成
通过以下命令安装 Pica 的 Bright Data 集成包:pip install pica-langchain
选择您偏好的 Bright Data 工具
Pica 连接器 提供两种主要的 Bright Data 集成工具:import os
from langchain_openai import ChatOpenAI
from langchain.agents import AgentType
from pica_langchain import PicaClient, create_pica_agent
from pica_langchain.models import PicaClientOptions
def main():
try:
pica_client = PicaClient(
secret=os.environ["PICA_SECRET"],
options=PicaClientOptions(
connectors=["test::bright-data::default::fd583f2344fa414293bdda4f240258c1"] # Initialize all available connections or pass specific connector keys
)
)
pica_client.initialize()
llm = ChatOpenAI(
temperature=0,
model="gpt-4o",
)
# Create an agent with Pica tools
agent = create_pica_agent(
client=pica_client,
llm=llm,
agent_type=AgentType.OPENAI_FUNCTIONS,
)
# Execute a multi-step workflow using the GitHub Connector
result = agent.invoke({
"input": (
"Trigger Synchronous Web Scraping and Retrieve Results, use this dataset ID : gd_l7q7dkf244hwjntr0 and search for this URL : https://www.amazon.com/dp/B0D2Q9397Y?th=1&psc=1"
)
})
print(f"\nWorkflow Result:\n {result}")
except Exception as e:
print(f"ERROR: An unexpected error occurred: {e}")
if __name__ == "__main__":
main()