Skip to content

Enhanced Docs #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 0 additions & 7 deletions scrapegraph-py/.pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,3 @@ repos:
- id: end-of-file-fixer
- id: check-yaml
exclude: mkdocs.yml

- repo: https://github.com/gitguardian/ggshield
rev: v1.33.0
hooks:
- id: ggshield
language_version: python3
stages: [commit]
45 changes: 23 additions & 22 deletions scrapegraph-py/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,19 @@ Official Python SDK for the ScrapeGraph AI API - Smart web scraping powered by A
pip install scrapegraph-py
```

### Using Poetry (Recommended)
### Using uv

We recommend using [uv](https://docs.astral.sh/uv/) to install the dependencies and pre-commit hooks.

```
# Install poetry if you haven't already
pip install poetry
# Install uv if you haven't already
pip install uv

# Install dependencies
poetry install
uv sync

# Install pre-commit hooks
poetry run pre-commit install
uv run pre-commit install
```

## 🔧 Quick Start
Expand All @@ -51,15 +53,15 @@ from scrapegraph_py.logger import get_logger
logger = get_logger(level="DEBUG")

# Initialize client
client = SyncClient(api_key="sgai-your-api-key")
sgai_client = SyncClient(api_key="your-api-key-here")

# Make a request
response = client.smartscraper(
response = sgai_client.smartscraper(
website_url="https://example.com",
user_prompt="Extract the main heading and description"
)

print(response)
print(response["result"])
```

## 🎯 Examples
Expand All @@ -71,12 +73,12 @@ import asyncio
from scrapegraph_py import AsyncClient

async def main():
async with AsyncClient(api_key="sgai-your-api-key") as client:
response = await client.smartscraper(
async with AsyncClient(api_key="your-api-key-here") as sgai_client:
response = await sgai_client.smartscraper(
website_url="https://example.com",
user_prompt="Extract the main heading"
user_prompt="Summarize the main content"
)
print(response)
print(response["result"])

asyncio.run(main())
```
Expand All @@ -92,12 +94,14 @@ class WebsiteData(BaseModel):
title: str = Field(description="The page title")
description: str = Field(description="The meta description")

client = SyncClient(api_key="sgai-your-api-key")
response = client.smartscraper(
sgai_client = SyncClient(api_key="your-api-key-here")
response = sgai_client.smartscraper(
website_url="https://example.com",
user_prompt="Extract the title and description",
output_schema=WebsiteData
)

print(response["result"])
```
</details>

Expand All @@ -112,27 +116,24 @@ For detailed documentation, visit [docs.scrapegraphai.com](https://docs.scrapegr
1. Clone the repository:
```
git clone https://github.com/ScrapeGraphAI/scrapegraph-sdk.git
cd scrapegraph-sdk
cd scrapegraph-sdk/scrapegraph-py
```

2. Install dependencies:
```
poetry install
uv sync
```

3. Install pre-commit hooks:
```
poetry run pre-commit install
uv run pre-commit install
```

### Running Tests

```
# Run all tests
poetry run pytest

# Run with coverage
poetry run pytest --cov=scrapegraph_py
uv run pytest

# Run specific test file
poetry run pytest tests/test_client.py
Expand Down Expand Up @@ -167,4 +168,4 @@ Contributions are welcome! Please feel free to submit a Pull Request. For major

---

Made with ❤️ by [ScrapeGraph AI](https://scrapegraphai.com)
Made with ❤️ by [ScrapeGraph AI](https://scrapegraphai.com)
24 changes: 12 additions & 12 deletions scrapegraph-py/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,6 @@ authors = [
{ name = "Lorenzo Padoan", email = "[email protected]" }
]

dependencies = [
"requests>=2.32.3",
"pydantic>=2.10.2",
"python-dotenv>=1.0.1",
"aiohttp>=3.11.8",
"requests>=2.32.3",
"validators>=0.34.0",
]

license = "MIT"
readme = "README.md"
homepage = "https://scrapegraphai.com/"
Expand All @@ -43,7 +34,16 @@ classifiers = [
"Programming Language :: Python :: 3",
"Operating System :: OS Independent",
]
requires-python = ">=3.9,<4.0"
requires-python = ">=3.10,<4.0"

dependencies = [
"requests>=2.32.3",
"pydantic>=2.10.2",
"python-dotenv>=1.0.1",
"aiohttp>=3.11.8",
"requests>=2.32.3",
"validators>=0.34.0",
]

[project.optional-dependencies]
docs = ["sphinx==6.0", "furo==2024.5.6"]
Expand Down Expand Up @@ -73,7 +73,7 @@ dev-dependencies = [

[tool.black]
line-length = 88
target-version = ["py39"]
target-version = ["py310"]

[tool.isort]
profile = "black"
Expand All @@ -86,7 +86,7 @@ select = ["F", "E", "W", "C"]
ignore = ["E203", "E501"] # Ignore conflicts with Black

[tool.mypy]
python_version = "3.9"
python_version = "3.10"
strict = true
disallow_untyped_calls = true
ignore_missing_imports = true
Expand Down
Loading
Loading