Back to prompt library
Add Web Scraping and Compliance Reasoning
Linked challenge: Global Compliance Intelligence Agent
Prompt source
implementation16 lines5 sectionsNo variables1 code block
Enhance your `PolicyExtractorAgent` to include a tool that performs web scraping using `BeautifulSoup` and `requests` (or `Playwright` for dynamic content) to fetch policy documents from specified URLs. Create a new agent method or a separate agent responsible for `ComplianceReport` generation. This agent should take a `TaxExemptionPolicy` and a `business_scenario` as input, use `Gemini 2.5 Pro` to reason about compliance, and output a validated `ComplianceReport`.
```python
from bs4 import BeautifulSoup
import requests
class WebScraperTool:
def scrape_url(self, url: str) -> str:
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
return soup.get_text()
class ComplianceAgent(PydanticAI):
def generate_report(self, policy: TaxExemptionPolicy, scenario: str) -> ComplianceReport:
# LLM call with prompt for compliance reasoning
pass
# Integrate WebScraperTool into PolicyExtractorAgent or orchestrate externally
# agent_with_scraper = PolicyExtractorAgent(llm_model=model, tools=[WebScraperTool()])
```