Created
March 20, 2025 11:33
-
-
Save davepoon/fc92a6f179ce79d7a3a1e506d0837353 to your computer and use it in GitHub Desktop.
Crawl4AI example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from crawl4ai import WebCrawler | |
from crawl4ai.extraction_strategy import LLMExtractionStrategy | |
from pydantic import BaseModel, Field | |
class OpenAIModelFee(BaseModel): | |
model_name: str | |
input_fee: str | |
output_fee: str | |
url = 'https://openai.com/api/pricing/' | |
crawler = WebCrawler() | |
crawler.warmup() | |
result = crawler.run( | |
url=url, | |
extraction_strategy=LLMExtractionStrategy( | |
provider="openai/gpt-4o", | |
api_token='your_api_key', | |
schema=OpenAIModelFee.schema(), | |
instruction="Extract all model names and their fees." | |
) | |
) | |
print(result.extracted_content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment