import requests from bs4 import BeautifulSoup def scrape_url(url): try: res = requests.get(url, timeout=10, headers={'User-Agent': 'Mozilla/5.0'}) res.raise_for_status() soup = BeautifulSoup(res.text, 'html.parser') for tag in soup(['script','style','']): tag.decompose() text = soup.get_text(separator='\n', strip=True) return text except Exception as e: return f"[Error scraping {url}: {e}]"