Newspaper4k

Newspaper4kTools uses the newspaper4k library to expose a read_article function that returns JSON with an article's title, authors, publish date, and text.

Newspaper4kTools enable an Agent to read news articles using the Newspaper4k library.

Prerequisites

The following example requires the newspaper4k and lxml_html_clean libraries.

uv pip install -U agno newspaper4k lxml_html_clean openai

Example

The following agent will summarize the article: https://www.rockymountaineer.com/blog/experience-icefields-parkway-scenic-drive-lifetime.

cookbook/91_tools/newspaper4k_tools.py
from agno.agent import Agent
from agno.tools.newspaper4k import Newspaper4kTools

agent = Agent(tools=[Newspaper4kTools()], debug_mode=True)
agent.print_response("Please summarize https://www.rockymountaineer.com/blog/experience-icefields-parkway-scenic-drive-lifetime")

The agent can summarize the extracted article, as in the example. The toolkit itself only downloads and parses it; include_summary=True does not run Newspaper4k's NLP summarizer.

Toolkit Params

ParameterTypeDefaultDescription
enable_read_articleboolTrueEnables the functionality to read the full content of an article.
include_summaryboolFalseInclude an existing article summary. The adapter does not call nlp() to generate it, so current Newspaper4k normally leaves it empty.
article_lengthOptional[int]NoneTruncate returned article text after extraction; does not limit processing or summary length.
allboolFalseEnables all functionality.

Toolkit Functions

FunctionDescription
read_articleReads the full content of an article from a URL. Returns JSON containing the article title, authors, publish date, and text.

Developer Resources