© 2026FindAgent  · @simprr
返回列表
o

oxylabs/oxylabs-ai-studio-py

Structured data gathering from any website using AI-powered scraper, crawler, and browser automation. Scraping and crawling with natural language prompts. Equip your LLM agents with fresh data. AI Studio python SDK for intelligent web data gathering.

ai-crawlerai-scraperai-scrapingai-searchai-toolsai-web-scraperproxy-scraperpython-aiweb-scrapingweb-scraping-aiweb-scraping-apiweb-scraping-python
⭐

2.6k

Stars

🔱

22

Forks

👁

7

Watchers

📋

2

Issues

PythonMIT创建于 2025/6/17更新于 今天
在 GitHub 上查看访问主页
README
由 Gemini 翻译整理

OxyLabs AI Studio Python SDK

AI-Studio Python (1)

YouTube

这是一个简洁的 Python SDK,用于与 Oxylabs AI Studio API 服务进行无缝交互,包括 AI-Scraper、AI-Crawler、AI-Browser-Agent 以及其他数据提取工具。

环境要求

  • python 3.10 及以上版本
  • API KEY

安装

pip install oxylabs-ai-studio

使用方法

爬取 (AiCrawler.crawl)


from oxylabs_ai_studio.apps.ai_crawler import AiCrawler

crawler = AiCrawler(api_key="")

url = "https://oxylabs.io"
result = crawler.crawl(
    url=url,
    user_prompt="Find all pages with proxy products pricing",
    output_format="markdown",
    render_javascript=False,
    return_sources_limit=3,
    geo_location="United States",
)
print("Results:")
for item in result.data:
    print(item, "\n")

参数说明:

  • url (str): 开始爬取的 URL (必填)
  • user_prompt (str): 指导提取的自然语言提示词 (必填)
  • output_format (Literal["json", "markdown", "csv", "toon"]): 输出格式 (默认: "markdown")
  • schema (dict | None): 用于结构化提取的 JSON Schema (若 output_format 为 "json", "csv" 或 "toon" 时必填)
  • render_javascript (bool): 是否渲染 JavaScript (默认: False)
  • return_sources_limit (int): 返回的最大源数量 (默认: 25)
  • geo_location (str): ISO2 格式的代理位置或国家标准名称。详见 文档
  • max_credits (int | None): 可使用的最大积分 (可选)

抓取 (AiScraper.scrape)

from oxylabs_ai_studio.apps.ai_scraper import AiScraper

scraper = AiScraper(api_key="")

schema = scraper.generate_schema(prompt="want to parse developer, platform, type, price game title, genre (array) and description")
print(f"Generated schema: {schema}")

url = "https://sandbox.oxylabs.io/products/3"
result = scraper.scrape(
    url=url,
    output_format="json",
    schema=schema,
    render_javascript=False,
)
print(result)

参数说明:

  • url (str): 目标抓取 URL (必填)
  • output_format (Literal["json", "markdown", "csv", "screenshot", "toon"]): 输出格式 (默认: "markdown")
  • schema (dict | None): 用于结构化提取的 JSON Schema (若 output_format 为 "json", "csv" 或 "toon" 时必填)
  • render_javascript (bool | string): 是否渲染 JavaScript。可设置为 "auto",此时服务会自动检测是否需要渲染 (默认: False)
  • geo_location (str): ISO2 格式的代理位置或国家标准名称。详见 文档
  • user_agent (str): User-Agent 请求头。详情请参考 https://developers.oxylabs.io/scraping-solutions/web-scraper-api/features/http-context-and-job-management/user-agent-type

浏览器代理 (BrowserAgent.run)

from oxylabs_ai_studio.apps.browser_agent import BrowserAgent

browser_agent = BrowserAgent(api_key="")

schema = browser_agent.generate_schema(
    prompt="game name, platform, review stars and price"
)
print("schema: ", schema)

prompt = "Find if there is game 'super mario odyssey' in the store. If there is, find the price. Use search bar to find the game."
url = "https://sandbox.oxylabs.io/"
result = browser_agent.run(
    url=url,
    user_prompt=prompt,
    output_format="json",
    schema=schema,
)
print(result.data)

参数说明:

  • url (str): 开始浏览的 URL (必填)
  • user_prompt (str): 用于提取的自然语言提示词 (必填)
  • output_format (Literal["json", "markdown", "html", "screenshot", "csv", "toon"]): 输出格式 (默认: "markdown")
  • schema (dict | None): 用于结构化提取的 JSON Schema (若 output_format 为 "json", "csv" 或 "toon" 时必填)
  • geo_location (str): ISO2 格式的代理位置或国家标准名称。例如 'Germany' (首字母大写)

搜索 (AiSearch.search)

from oxylabs_ai_studio.apps.ai_search import AiSearch


search = AiSearch(api_key="")

query = "lasagna recipe"
result = search.search(
    query=query,
    limit=5,
    render_javascript=False,
    return_content=True,
)
print(result.data)

# 或者使用快速搜索
result = search.instant_search(
    query=query,
    limit=10,
)
print(result.data)
贡献者
KOam
项目信息
默认分支main
LicenseMIT License
创建时间2025/6/17
最近更新今天
GAI 中文摘要

oxylabs-ai-studio-py 是一个专为 Python 开发者设计的官方 SDK,用于无缝对接 Oxylabs AI Studio 的系列服务。该项目通过整合 AI 驱动的网页爬虫、刮取工具及浏览器代理,帮助用户利用自然语言指令实现复杂网页的结构化数据提取。

支持通过自然语言提示词(Prompt)指导数据抓取逻辑,降低了编写爬虫代码的门槛。提供 AI 网页爬虫与刮取功能,能够处理动态渲染及 JavaScript 页面。支持将抓取结果格式化输出为 JSON、Markdown、CSV 等多种结构化格式。集成高级浏览器代理技术,支持地理位置定位及自定义请求配置以提升爬取成功率。

该项目适用于需要为 LLM 智能体获取实时数据的开发者,以及希望通过自然语言快速从各类网站采集结构化信息的业务场景。