Skip to main content

News scraping and reporting.

Project description

newsscraper provides a framework for scraping web news with Selenium and Beautiful Soup. newsscraper will take care of remembering which news items where already read and creates results in form of json, csv, or html files.

A minimal scraper for newsscraper that fetches the newest questions from https://stackoverflow.com/questions can look like this:

# content of stackoverflow.py
import newsscraper
import sys

with newsscraper.Scraper(sys.argv) as scraper:
   driver = scraper.get_chrome()
   driver.get('https://stackoverflow.com/questions')
   for question in driver.find_elements_by_xpath('//a[@class="question-hyperlink"]'):
       scraper.add(question.get_attribute('href'), question.text)

Additional configuration can be provided with arguments:

python3 stackoverflow.py --headless --verbose report=html --out=$(date '+%Y-%m-%d %H:%M:%S').html

Run python3 stackoverflow.py -h for a list of all arguments.

Features

  • Remember already added news items

  • Create reports in json, csv, html, or a custom format

  • Merge multiple json reports

  • Custom command-line arguments

Roadmap

  • Proxy support

  • Sort items by date in HTML5 report

  • Tags in HTML5 report

  • Custom report templates

  • RSS reports

  • python2 support

Installation

pip3 install newsscraper

If you want to use the selenium drivers you have to download the corresponding third party drivers in the ./assets/ subdirectory to your script. newsscraper will also automatically load all add-ons you place in ./assets/.

Changes

  • 0.1.0 initial version

License

This project is licensed under the MIT License - see the LICENSE for details.

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

newsscraper-0.1.2.tar.gz (5.5 kB view details)

Uploaded Source

Built Distribution

newsscraper-0.1.2-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file newsscraper-0.1.2.tar.gz.

File metadata

  • Download URL: newsscraper-0.1.2.tar.gz
  • Upload date:
  • Size: 5.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.9

File hashes

Hashes for newsscraper-0.1.2.tar.gz
Algorithm Hash digest
SHA256 8841fe26a62589c35f3f907e8d03d85c1c3d5053be5d44ceaeb8e8a60e3a0bb7
MD5 e0cc187c5584138ec7b362e968dcbf9e
BLAKE2b-256 92f9fd36924a1660efcd19ab4ed60540cfe0bbc07b83a1c4042078439488102b

See more details on using hashes here.

File details

Details for the file newsscraper-0.1.2-py3-none-any.whl.

File metadata

  • Download URL: newsscraper-0.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.1 requests-toolbelt/0.9.1 tqdm/4.39.0 CPython/3.6.9

File hashes

Hashes for newsscraper-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8a1642f4addcb9c3e87f43f18b978c60af7c677de56cc2fe4ad69c6da21b5e83
MD5 81d302518d4d5ae8adb53cd4058b2cf9
BLAKE2b-256 856f35e23df3bcc06bb964b78efed33b60b6d28dfcf7ebc8e3854de579a97c83

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