Newspaper4k is an open-source Python library for simplified article discovery and extraction from news websites. It is an actively maintained fork of the 'newspaper3k' project, offering new features, bug fixes, and improved parsing performance. The current version is 0.9.5, with frequent updates to enhance language support, address compatibility issues, and improve article content extraction.
pip install newspaper4kVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to extract key information from a single news article using the `newspaper.article()` helper. It retrieves the title, authors, publish date, top image, and then performs NLP to get a summary and keywords. A commented-out example shows how to initialize and crawl an entire news source using `newspaper.build()` and iterate through its articles.
Upgrade your Python environment to 3.10 or newer.
Be prepared for potential breakages and monitor for updates to the library. Consider alternative methods if reliability is critical.
Verify NLP output for non-Western languages and consider external NLP libraries for more robust analysis if needed.
Implement delays between requests, use proxy rotation, and rotate user-agent strings. Install `protego` optional dependency for robots.txt enforcement. For heavily protected sites (e.g., Cloudflare), `cloudscraper` (optional dependency) or external tools like Playwright might be necessary.
Ensure `article.download()` and `article.parse()` are called sequentially before accessing article properties or running NLP.
Remove any usage of `text_cleaned` or `clean_doc`. The primary article text is available via `article.text`.