tool.py
1 """Firecrawl Tool Example. 2 3 This example demonstrates how to use the Firecrawl tool with PraisonAI agents. 4 5 Requirements: 6 pip install "praisonai[tools]" 7 export FIRECRAWL_API_KEY=your_api_key 8 9 Usage: 10 python tool.py 11 """ 12 13 import os 14 from praisonai_tools import FirecrawlTool 15 16 17 def main(): 18 # Check for API key 19 if not os.getenv("FIRECRAWL_API_KEY"): 20 print("Error: FIRECRAWL_API_KEY environment variable not set") 21 print("Get your API key from https://firecrawl.dev/") 22 return 23 24 # Initialize Firecrawl tool 25 firecrawl = FirecrawlTool() 26 27 # Example 1: Scrape a page 28 print("=" * 60) 29 print("Example 1: Scrape a Page") 30 print("=" * 60) 31 32 result = firecrawl.scrape("https://example.com") 33 34 if "error" in result: 35 print(f"Error: {result['error']}") 36 else: 37 print(f"URL: {result.get('url', 'N/A')}") 38 markdown = result.get('markdown', '') 39 print(f"Content preview: {markdown[:300]}...") 40 41 print("\n✅ Firecrawl tool working correctly!") 42 43 44 if __name__ == "__main__": 45 main()