Spaces:
Running
Running
| import pdfplumber | |
| from newspaper import Article | |
| def read_pdf(file): | |
| text = "" | |
| with pdfplumber.open(file) as pdf: | |
| for page in pdf.pages: | |
| page_text = page.extract_text() | |
| if page_text: | |
| text += page_text + "\n" | |
| return text.strip() | |
| def fetch_article_from_url(url): | |
| try: | |
| article = Article(url) | |
| article.download() | |
| article.parse() | |
| return article.text | |
| except Exception as e: | |
| return f"Failed to fetch article: {e}" | |