11import asyncio
2- from typing import List , Dict , Any
32
43from scrapegraph_py import AsyncClient
54from 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
3837async 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