> ## Documentation Index
> Fetch the complete documentation index at: https://praison.ai/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# Newspaper Agent

> News article extraction tools for AI agents.

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent
from praisonaiagents import extract_article

agent = Agent(
    name="News Reader",
    instructions="Extract and summarise news articles from URLs.",
    tools=[extract_article],
)
agent.start("Summarise the main points from this article URL")
```

The user pastes a news link; the agent extracts article text and returns a brief summary.

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
graph LR
    U[Input] --> A[Agent]
    A --> T[Tool]
    T --> O[Output]

    classDef agent fill:#8B0000,color:#fff
    classDef tool fill:#189AB4,color:#fff

    class A agent
    class U,O tool
    class T tool
```

```mermaid theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
sequenceDiagram
    participant User
    participant Agent
    participant Feature as Newspaper Agent

    User->>Agent: Request
    Agent->>Feature: Process request
    Feature-->>Agent: Result
    Agent-->>User: Response
```

<Note>
  **Prerequisites**

  * Python 3.10 or higher
  * PraisonAI Agents package installed
  * PraisonAI Tools package installed
  * `newspaper3k` package installed
</Note>

## Newspaper Tools

Use Newspaper Tools to extract and analyze news articles with AI agents.

<Steps>
  <Step title="Install Dependencies">
    First, install the required packages:

    ```bash theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    pip install praisonaiagents praisonai-tools newspaper3k
    ```
  </Step>

  <Step title="Import Components">
    Import the necessary components:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonaiagents import Agent, Task, AgentTeam
    from praisonai_tools import get_article, get_news_sources, get_articles_from_source, get_trending_topics
    ```
  </Step>

  <Step title="Create Agent">
    Create a news agent:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    news_agent = Agent(
        name="NewsAgent",
        role="News Analyst",
        goal="Collect and analyze news articles from various sources.",
        backstory="Expert in news gathering and content analysis.",
        tools=[get_article, get_news_sources, get_articles_from_source, get_trending_topics],
        reflection=False
    )
    ```
  </Step>

  <Step title="Define Task">
    Define the news task:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    news_task = Task(
        description="Analyze news articles about 'AI developments' from major tech news sources.",
        expected_output="Summary of key AI developments with source articles.",
        agent=news_agent,
        name="ai_news"
    )
    ```
  </Step>

  <Step title="Run Agent">
    Initialize and run the agent:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    agents = AgentTeam(
        agents=[news_agent],
        tasks=[news_task],
        process="sequential"
    )
    agents.start()
    ```
  </Step>
</Steps>

## Understanding Newspaper Tools

<Card title="What are Newspaper Tools?" icon="question">
  Newspaper Tools provide news article processing capabilities for AI agents:

  * Article extraction
  * Source management
  * Content analysis
  * Trend detection
  * Multi-language support
</Card>

## Key Components

<CardGroup cols={2}>
  <Card title="News Agent" icon="user-robot">
    Create specialized news agents:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    Agent(tools=[get_article, get_news_sources, get_articles_from_source, get_trending_topics])
    ```
  </Card>

  <Card title="News Task" icon="list-check">
    Define news tasks:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    Task(description="news_query")
    ```
  </Card>

  <Card title="Process Types" icon="arrows-split-up-and-left">
    Sequential or parallel processing:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    process="sequential"
    ```
  </Card>

  <Card title="Article Options" icon="sliders">
    Customize article retrieval:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    language="en", limit=10
    ```
  </Card>
</CardGroup>

## Available Functions

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonai_tools import get_article
from praisonai_tools import get_news_sources
from praisonai_tools import get_articles_from_source
from praisonai_tools import get_trending_topics
```

## Examples

### Basic News Agent

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent, Task, AgentTeam
from praisonai_tools import get_article, get_news_sources, get_articles_from_source, get_trending_topics

# Create news agent
news_agent = Agent(
    name="NewsExpert",
    role="News Analyst",
    goal="Gather and analyze news content efficiently.",
    backstory="Expert in news analysis and content curation.",
    tools=[get_article, get_news_sources, get_articles_from_source, get_trending_topics],
    reflection=False
)

# Define news task
news_task = Task(
    description="Analyze tech news trends.",
    expected_output="Tech news analysis report.",
    agent=news_agent,
    name="tech_news_analysis"
)

# Run agent
agents = AgentTeam(
    agents=[news_agent],
    tasks=[news_task],
    process="sequential"
)
agents.start()
```

### Advanced News Analysis with Multiple Agents

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent, Task, AgentTeam
from praisonai_tools import get_article, get_news_sources, get_articles_from_source, get_trending_topics

# Create news collection agent
collector_agent = Agent(
    name="Collector",
    role="News Collector",
    goal="Gather comprehensive news coverage.",
    tools=[get_article, get_news_sources, get_articles_from_source, get_trending_topics],
    reflection=False
)

# Create analysis agent
analysis_agent = Agent(
    name="Analyzer",
    role="Content Analyst",
    goal="Analyze news content and identify trends.",
    backstory="Expert in news analysis and trend identification.",
    reflection=False
)

# Define tasks
collection_task = Task(
    description="Collect news articles about renewable energy developments.",
    agent=collector_agent,
    name="energy_news"
)

analysis_task = Task(
    description="Analyze the articles and identify key trends and breakthroughs.",
    agent=analysis_agent,
    name="news_analysis"
)

# Run agents
agents = AgentTeam(
    agents=[collector_agent, analysis_agent],
    tasks=[collection_task, analysis_task],
    process="sequential"
)
agents.start()
```

## Best Practices

<AccordionGroup>
  <Accordion title="Agent Configuration">
    Configure agents with clear news focus:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    from praisonai_tools import get_article, get_news_sources, get_articles_from_source, get_trending_topics

    Agent(
        name="NewsAnalyst",
        role="News Specialist",
        goal="Analyze news content effectively",
        tools=[get_article, get_news_sources, get_articles_from_source, get_trending_topics]
    )
    ```
  </Accordion>

  <Accordion title="Task Definition">
    Define specific news objectives:

    ```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
    Task(
        description="Analyze tech news from major sources for AI developments",
        expected_output="Trend analysis with key findings"
    )
    ```
  </Accordion>
</AccordionGroup>

## Common Patterns

### News Monitoring

```python theme={"theme":{"light":"vitesse-light","dark":"vitesse-dark"}}
from praisonaiagents import Agent, Task, AgentTeam
from praisonai_tools import get_article, get_news_sources, get_articles_from_source, get_trending_topics

# News monitor agent
monitor = Agent(
    name="Monitor",
    role="News Monitor",
    tools=[get_article, get_news_sources, get_articles_from_source, get_trending_topics]
)

# Analysis agent
analyst = Agent(
    name="Analyst",
    role="News Analyst"
)

# Define tasks
monitor_task = Task(
    description="Monitor tech news sources",
    agent=monitor
)

analysis_task = Task(
    description="Analyze news trends",
    agent=analyst
)

# Run workflow
agents = AgentTeam(
    agents=[monitor, analyst],
    tasks=[monitor_task, analysis_task]
)
```

## Related

<CardGroup cols={2}>
  <Card title="Custom Tools" icon="wrench" href="/docs/tools/custom">
    Build your own agent tools
  </Card>

  <Card title="Tools Overview" icon="toolbox" href="/docs/tools/tools">
    Browse PraisonAI tool documentation
  </Card>
</CardGroup>
