Metadata-Version: 2.5
Name: crewai-scrapeit
Version: 0.1.0
Summary: ScrapeIt tools for CrewAI agents: scrape any web page and search Google through the ScrapeIt API.
Project-URL: Homepage, https://www.scrapeit.io/
Project-URL: Documentation, https://docs.scrapeit.io/products/ai-frameworks#crewai
License-Expression: MIT
Keywords: ai-agents,crewai,crewai-tools,google-search,scrapeit,web-scraping
Classifier: Intended Audience :: Developers
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Typing :: Typed
Requires-Python: >=3.11
Requires-Dist: crewai<2.0.0,>=1.0.0
Requires-Dist: scrapeit-sdk<0.5,>=0.4.0
Provides-Extra: dev
Requires-Dist: pytest-asyncio==1.5.0; extra == 'dev'
Requires-Dist: pytest==9.2.0; extra == 'dev'
Description-Content-Type: text/markdown

# crewai-scrapeit

[ScrapeIt](https://www.scrapeit.io/) tools for [CrewAI](https://docs.crewai.com/) agents: scrape any web page
and search Google. ScrapeIt fetches each page through its proxies, renders JavaScript when the page needs it
and gets past anti-bot protection, so an agent reads the real page instead of a block or an empty shell.

| Tool                 | Name                     | Input                                           | Returns                                 |
| -------------------- | ------------------------ | ----------------------------------------------- | --------------------------------------- |
| `ScrapeitScrapeTool` | `scrapeit_scrape`        | `url`                                           | The page as markdown (or text, HTML).   |
| `ScrapeitSearchTool` | `scrapeit_google_search` | `query`, optional `country`, `language`, `page` | The parsed Google results page as JSON. |

## Install

```bash
pip install crewai-scrapeit
```

Python 3.11+, CrewAI 1.x. Built on the official [`scrapeit-sdk`](https://pypi.org/project/scrapeit-sdk/).

## Authentication

Create an API key in the ScrapeIt dashboard under **Workspace → API Keys** (scope `scrape:web`) and set it in
the environment:

```bash
export SCRAPEIT_API_KEY="YOUR_SCRAPEIT_API_KEY"
```

Or pass it to a tool: `ScrapeitScrapeTool(api_key="...")`. The key is sent only in the `x-api-key` header to
`https://api.scrapeit.io`; it is a private attribute, so it never appears in the tool's `repr`, in CrewAI
checkpoints or in error messages.

## Usage

```python
from crewai import Agent, Crew, Task
from crewai_scrapeit import ScrapeitScrapeTool, ScrapeitSearchTool

researcher = Agent(
    role="Web researcher",
    goal="Answer questions with facts from current web pages",
    backstory="You search Google first, then read the most relevant pages.",
    tools=[ScrapeitSearchTool(), ScrapeitScrapeTool()],
)
task = Task(
    description="What is example.com used for? Read the page itself.",
    expected_output="Two sentences and the URL you read.",
    agent=researcher,
)

# The agent's LLM comes from CrewAI's own settings (OPENAI_API_KEY by default).
print(Crew(agents=[researcher], tasks=[task]).kickoff())
```

Call a tool directly, without an agent:

```python
ScrapeitScrapeTool().run(url="https://example.com")  # "Example Domain ..."
ScrapeitSearchTool().run(query="best coffee maker", country="us")  # '{"organic_results": [...], ...}'
```

`ScrapeitScrapeTool(params={...})` sets [Web Scraping API parameters](https://docs.scrapeit.io/products/web-scraping-api)
for every call, for example `{"jsRendering": True, "proxyType": "residential", "proxyCountry": "us"}`, and
`output_format="text"` returns plain text instead of markdown. On CrewAI releases with async tools,
`await tool.arun(...)` runs on `scrapeit.AsyncScrapeit`.

## Errors

A failed call raises `RuntimeError` with the stable ScrapeIt error code, its message and the correlation id,
for example `ScrapeIt error INSUFFICIENT_CREDITS: ... (correlation_id ...)`; CrewAI hands that text to the
agent. The original `scrapeit.ScrapeitError` is the exception's `__cause__`. A missing key fails when a tool is
created (`MISSING_API_KEY`). The agent never gets an empty or a challenge text for a page: a scrape that failed
is `SCRAPE_FAILED` (nothing charged), a site that answered with its anti-bot page is `TARGET_BLOCKED`
(charged: retry with `jsRendering` or residential proxies).

## Credits

Every scrape and search spends credits from your ScrapeIt plan, the same as a direct API call; failures on
ScrapeIt's side are free. Agents may call tools several times per task, so give the crew its own API key and
watch the Usage page. See [billing and credits](https://docs.scrapeit.io/guide/billing-and-credits).

## Links

- [Docs: AI frameworks](https://docs.scrapeit.io/products/ai-frameworks)
- [Web Scraping API reference](https://docs.scrapeit.io/products/web-scraping-api)
- [Google SERP API](https://docs.scrapeit.io/products/google-serp-api)
- [Error codes](https://docs.scrapeit.io/guide/errors)
