Skip to content

Commit fd2f5d1

Browse files
committed
fixed the examples
1 parent ffc32ce commit fd2f5d1

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

__pycache__/test_sdk.cpython-312.pyc

838 Bytes
Binary file not shown.

scrapegraph-py/examples/async/async_smartscraper_infinite_scroll_example.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import asyncio
2-
from typing import List, Dict, Any
32

43
from scrapegraph_py import AsyncClient
54
from scrapegraph_py.logger import sgai_logger
@@ -16,15 +15,15 @@ async def scrape_companies(client: AsyncClient, url: str, batch: str) -> None:
1615
user_prompt="Extract all company information from this page, including name, description, and website",
1716
number_of_scrolls=10,
1817
)
19-
2018
# Process the results
21-
companies = response.get("result", [])
19+
companies = response.get("result", {}).get("companies", [])
2220
if not companies:
2321
print(f"No companies found for batch {batch}")
2422
return
2523

2624
# Save or process the companies data
2725
print(f"Found {len(companies)} companies in batch {batch}")
26+
2827
for company in companies:
2928
print(f"Company: {company.get('name', 'N/A')}")
3029
print(f"Description: {company.get('description', 'N/A')}")
@@ -37,13 +36,13 @@ async def scrape_companies(client: AsyncClient, url: str, batch: str) -> None:
3736

3837
async def main():
3938
# Initialize async client
40-
client = AsyncClient(api_key="your-api-key-here")
39+
client = AsyncClient(api_key="sgai-4cf4a4f5-87f7-457a-8c58-0790ecaf323e")
4140

4241
try:
4342
# Example YC batch URLs
4443
batch_urls = {
45-
"W24": "https://www.ycombinator.com/companies?batch=W24",
46-
"S23": "https://www.ycombinator.com/companies?batch=S23"
44+
"W24": "https://www.ycombinator.com/companies?batch=Winter%202024",
45+
"S23": "https://www.ycombinator.com/companies?batch=Summer%202023"
4746
}
4847

4948
# Create tasks for each batch

0 commit comments

Comments
 (0)