Skip to main content

The all-in-one Python package for seamless newspaper article indexing, scraping, and processing – supports public and premium content!

Project description

Newspaper-Scraper

The all-in-one Python package for seamless newspaper article indexing, scraping, and processing – supports public and premium content!

Intro

While tools like newspaper3k and goose3 can be used for extracting articles from news websites, they need a dedicated article url for older articles and do not support paywall content. This package aims to solve these issues by providing a unified interface for indexing, extracting and processing articles from newspapers.

  1. Indexing: Index articles from a newspaper website using the beautifulsoup package for public articles and selenium for paywall content.
  2. Extraction: Extract article content using the goose3 package.
  3. Processing: Process articles for nlp features using the spaCy package.

The indexing functionality is based on a dedicated file for each newspaper. A few newspapers are already supported, but it is easy to add new ones.

Supported Newspapers

Logo Newspaper Country Time span Number of articles
Der Spiegel Germany Since 2000 tbd
Die Welt Germany Since 2000 tbd
Bild Germany Since 2006 tbd

Setup

It is recommended to install the package in an dedicated Python environment.
To install the package via pip, run the following command:

pip install newspaper-scraper

To also include the nlp extraction functionality (via spaCy), run the following command:

pip install newspaper-scraper[nlp]

Usage

To index, extract and process all public and premium articles from Der Spiegel, published in August 2021, run the following code:

import newspaper_scraper as ns  
from credentials import username, password  
  
with ns.Spiegel(db_file='articles.db') as spiegel:  
spiegel.index_published_articles('2021-08-01', '2021-08-31')  
spiegel.scrape_public_articles()  
spiegel.scrape_premium_articles(username=username, password=password)  
spiegel.nlp()  

This will create a sqlite database file called articles.db in the current working directory. The database contains the following tables:

  • tblArticlesIndexed: Contains all indexed articles with their scraping/ processing status and whether they are public or premium content.
  • tblArticlesScraped: Contains metadata for all parsed articles, provided by goose3.
  • tblArticlesProcessed: Contains nlp features of the cleaned article text, provided by spaCy.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

newspaper_scraper-0.1.3.tar.gz (15.1 kB view details)

Uploaded Source

Built Distribution

newspaper_scraper-0.1.3-py3-none-any.whl (19.1 kB view details)

Uploaded Python 3

File details

Details for the file newspaper_scraper-0.1.3.tar.gz.

File metadata

  • Download URL: newspaper_scraper-0.1.3.tar.gz
  • Upload date:
  • Size: 15.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.11.2

File hashes

Hashes for newspaper_scraper-0.1.3.tar.gz
Algorithm Hash digest
SHA256 6462895e5d484f93163624d1f0a8f1839c12cfad3cb94ea7c9e47e730457a883
MD5 e324f8cf62de57f9c1f445a6cb005d3a
BLAKE2b-256 951e6d8782bcd9b3f23f19679105169a8396a06747ee4cffb13b9d088d8f88aa

See more details on using hashes here.

File details

Details for the file newspaper_scraper-0.1.3-py3-none-any.whl.

File metadata

File hashes

Hashes for newspaper_scraper-0.1.3-py3-none-any.whl
Algorithm Hash digest
SHA256 422841b530f15b86f1f2f2e4e182b388445a98142600d8a16488226d2b133dbe
MD5 06b616290ed23c362536c4d296155279
BLAKE2b-256 2ade2683974a25270ef858432332a248e2d1b9790eacea6751b3286d2791d12a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page