ContiAI / tools /scraper /no_agent /pdf_extractor.py
ziadsameh32's picture
Add login page
325b94c
Raw
History Blame Contribute Delete
437 Bytes
import requests
import io
from PyPDF2 import PdfReader
def extract_pdf_content(url: str) -> str:
try:
pdf_bytes = requests.get(url, timeout=10).content
pdf_file = io.BytesIO(pdf_bytes)
reader = PdfReader(pdf_file)
text = ""
for page in reader.pages:
text += page.extract_text() or ""
return text.strip()
except Exception as e:
return f"PDF_ERROR: {str(e)}"