Use this file to discover all available pages before exploring further.
Learn how to extract trending repository information from GitHub using ScrapeGraphAIβs Extract service. This example demonstrates how to gather repository statistics, descriptions, and popularity metrics.
from pydantic import BaseModel, Fieldfrom typing import Listfrom scrapegraph_py import ScrapeGraphAI# Schema for Trending Repositoriesclass RepositorySchema(BaseModel): name: str = Field(description="Name of the repository (e.g., 'owner/repo')") description: str = Field(description="Description of the repository") stars: int = Field(description="Star count of the repository") forks: int = Field(description="Fork count of the repository") today_stars: int = Field(description="Stars gained today") language: str = Field(description="Programming language used")# Schema that contains a list of repositoriesclass ListRepositoriesSchema(BaseModel): repositories: List[RepositorySchema] = Field(description="List of github trending repositories")sgai = ScrapeGraphAI() # reads SGAI_API_KEY from envres = sgai.extract( "Extract trending repository information", url="https://github.com/trending", schema=ListRepositoriesSchema.model_json_schema(),)if res.status == "success": print(res.data.json_data)