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 openaiExample
The following agent will summarize the article: https://www.rockymountaineer.com/blog/experience-icefields-parkway-scenic-drive-lifetime.
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
| Parameter | Type | Default | Description |
|---|---|---|---|
enable_read_article | bool | True | Enables the functionality to read the full content of an article. |
include_summary | bool | False | Include an existing article summary. The adapter does not call nlp() to generate it, so current Newspaper4k normally leaves it empty. |
article_length | Optional[int] | None | Truncate returned article text after extraction; does not limit processing or summary length. |
all | bool | False | Enables all functionality. |
Toolkit Functions
| Function | Description |
|---|---|
read_article | Reads the full content of an article from a URL. Returns JSON containing the article title, authors, publish date, and text. |