All Toolsโ€บAI News Summary Generator
๐Ÿ”ง AI newsApril 13, 2026โœ… Tests passing

AI News Summary Generator

Fetches AI news articles and generates concise summaries for quick consumption. Saves developers time by extracting essential information from long articles.

What It Does

  • Fetches AI news articles from URLs or RSS feeds.
  • Uses NLP summarization models to generate concise summaries.
  • Exports summaries to text or JSON files for further use.

Installation

  • Python 3.8+
  • requests
  • beautifulsoup4
  • transformers

Usage

Run the tool with the following command:

python ai_news_summary_generator.py --urls <list_of_urls> --output <output_file> --format <text|json>

Example

python ai_news_summary_generator.py --urls https://news.ai/article1 https://news.ai/article2 --output summaries.json --format json

This will fetch the articles from the provided URLs, generate summaries, and save them in a JSON file named summaries.json.

Source Code

import argparse
import json
import requests
from bs4 import BeautifulSoup
from transformers import pipeline

def fetch_articles(urls):
    """Fetches the content of articles from the given URLs."""
    articles = []
    for url in urls:
        try:
            response = requests.get(url, timeout=10)
            response.raise_for_status()
            soup = BeautifulSoup(response.text, 'html.parser')
            # Extract text content from the article
            paragraphs = soup.find_all('p')
            content = ' '.join(p.get_text() for p in paragraphs)
            articles.append({'url': url, 'content': content})
        except requests.RequestException as e:
            print(f"Error fetching {url}: {e}")
    return articles

def summarize_articles(articles, summarizer):
    """Summarizes the content of the articles using a summarization model."""
    summaries = []
    for article in articles:
        try:
            summary = summarizer(article['content'], max_length=130, min_length=30, do_sample=False)
            summaries.append({'url': article['url'], 'summary': summary[0]['summary_text']})
        except Exception as e:
            print(f"Error summarizing article from {article['url']}: {e}")
    return summaries

def save_summaries(summaries, output_file, output_format):
    """Saves the summaries to a file in the specified format."""
    try:
        with open(output_file, 'w', encoding='utf-8') as f:
            if output_format == 'json':
                json.dump(summaries, f, indent=4)
            else:
                for summary in summaries:
                    f.write(f"URL: {summary['url']}\n")
                    f.write(f"Summary: {summary['summary']}\n\n")
    except Exception as e:
        print(f"Error saving summaries: {e}")

def main():
    parser = argparse.ArgumentParser(description="AI News Summary Generator")
    parser.add_argument('--urls', nargs='+', help="List of article URLs to summarize", required=True)
    parser.add_argument('--output', help="Output file to save summaries", required=True)
    parser.add_argument('--format', choices=['text', 'json'], default='text', help="Output format (text or json)")
    args = parser.parse_args()

    # Load the summarization pipeline
    summarizer = pipeline('summarization')

    # Fetch articles
    articles = fetch_articles(args.urls)

    # Summarize articles
    summaries = summarize_articles(articles, summarizer)

    # Save summaries
    save_summaries(summaries, args.output, args.format)

if __name__ == "__main__":
    main()

Community

Downloads

ยทยทยท

Rate this tool

No ratings yet โ€” be the first!

Details

Tool Name
ai_news_summary_generator
Category
AI news
Generated
April 13, 2026
Tests
Passing โœ…

Quick Install

Clone just this tool:

git clone --depth 1 --filter=blob:none --sparse \
  https://github.com/ptulin/autoaiforge.git
cd autoaiforge
git sparse-checkout set generated_tools/2026-04-13/ai_news_summary_generator
cd generated_tools/2026-04-13/ai_news_summary_generator
pip install -r requirements.txt 2>/dev/null || true
python ai_news_summary_generator.py
AI News Summary Generator โ€” AI Tools by AutoAIForge