from newspaper import Article from transformers import pipeline article_summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6") # Replace with your actual token def extract_article_text(url): article = Article(url) article.download() article.parse() return article.text def summarize_article(text): summary = article_summarizer(text, max_length=150, min_length=50, do_sample=False) return summary[0]['summary_text']