@@ -25,17 +25,19 @@ Official Python SDK for the ScrapeGraph AI API - Smart web scraping powered by A
25
25
pip install scrapegraph-py
26
26
```
27
27
28
- ### Using Poetry (Recommended)
28
+ ### Using uv
29
+
30
+ We recommend using [ uv] ( https://docs.astral.sh/uv/ ) to install the dependencies and pre-commit hooks.
29
31
30
32
```
31
- # Install poetry if you haven't already
32
- pip install poetry
33
+ # Install uv if you haven't already
34
+ pip install uv
33
35
34
36
# Install dependencies
35
- poetry install
37
+ uv sync
36
38
37
39
# Install pre-commit hooks
38
- poetry run pre-commit install
40
+ uv run pre-commit install
39
41
```
40
42
41
43
## 🔧 Quick Start
@@ -51,15 +53,15 @@ from scrapegraph_py.logger import get_logger
51
53
logger = get_logger(level = " DEBUG" )
52
54
53
55
# Initialize client
54
- client = SyncClient(api_key = " sgai- your-api-key" )
56
+ sgai_client = SyncClient(api_key = " your-api-key-here " )
55
57
56
58
# Make a request
57
- response = client .smartscraper(
59
+ response = sgai_client .smartscraper(
58
60
website_url = " https://example.com" ,
59
61
user_prompt = " Extract the main heading and description"
60
62
)
61
63
62
- print (response)
64
+ print (response[ " result " ] )
63
65
```
64
66
65
67
## 🎯 Examples
@@ -71,12 +73,12 @@ import asyncio
71
73
from scrapegraph_py import AsyncClient
72
74
73
75
async def main ():
74
- async with AsyncClient(api_key = " sgai- your-api-key" ) as client :
75
- response = await client .smartscraper(
76
+ async with AsyncClient(api_key = " your-api-key-here " ) as sgai_client :
77
+ response = await sgai_client .smartscraper(
76
78
website_url = " https://example.com" ,
77
- user_prompt = " Extract the main heading "
79
+ user_prompt = " Summarize the main content "
78
80
)
79
- print (response)
81
+ print (response[ " result " ] )
80
82
81
83
asyncio.run(main())
82
84
```
@@ -92,12 +94,14 @@ class WebsiteData(BaseModel):
92
94
title: str = Field(description = " The page title" )
93
95
description: str = Field(description = " The meta description" )
94
96
95
- client = SyncClient(api_key = " sgai- your-api-key" )
96
- response = client .smartscraper(
97
+ sgai_client = SyncClient(api_key = " your-api-key-here " )
98
+ response = sgai_client .smartscraper(
97
99
website_url = " https://example.com" ,
98
100
user_prompt = " Extract the title and description" ,
99
101
output_schema = WebsiteData
100
102
)
103
+
104
+ print (response[" result" ])
101
105
```
102
106
</details >
103
107
@@ -112,27 +116,24 @@ For detailed documentation, visit [docs.scrapegraphai.com](https://docs.scrapegr
112
116
1 . Clone the repository:
113
117
```
114
118
git clone https://github.com/ScrapeGraphAI/scrapegraph-sdk.git
115
- cd scrapegraph-sdk
119
+ cd scrapegraph-sdk/scrapegraph-py
116
120
```
117
121
118
122
2 . Install dependencies:
119
123
```
120
- poetry install
124
+ uv sync
121
125
```
122
126
123
127
3 . Install pre-commit hooks:
124
128
```
125
- poetry run pre-commit install
129
+ uv run pre-commit install
126
130
```
127
131
128
132
### Running Tests
129
133
130
134
```
131
135
# Run all tests
132
- poetry run pytest
133
-
134
- # Run with coverage
135
- poetry run pytest --cov=scrapegraph_py
136
+ uv run pytest
136
137
137
138
# Run specific test file
138
139
poetry run pytest tests/test_client.py
@@ -167,4 +168,4 @@ Contributions are welcome! Please feel free to submit a Pull Request. For major
167
168
168
169
---
169
170
170
- Made with ❤️ by [ ScrapeGraph AI] ( https://scrapegraphai.com )
171
+ Made with ❤️ by [ ScrapeGraph AI] ( https://scrapegraphai.com )
0 commit comments