Skip to main content

news-watch is a Python package that scrapes structured news data from Indonesia's top news websites, offering keyword and date filtering queries for targeted research.

Project description

news-watch: Indonesia's top news websites scraper

PyPI version Build Status PyPI Downloads

news-watch is a Python package that scrapes structured news data from Indonesia's top news websites, offering keyword and date filtering queries for targeted research

⚠️ Ethical Considerations & Disclaimer ⚠️

Purpose: For educational and research purposes only. Not designed for commercial use that could be detrimental to news source providers.

User Responsibility: Users must comply with each website's Terms of Service and robots.txt. Aggressive scraping may lead to IP blocking. Scrape responsibly and respect server limitations.

Installation

Using pip (standard)

pip install news-watch
playwright install chromium

Development setup: see https://okky.dev/news-watch/getting-started/

Performance Notes

⚠️ Works best locally. Cloud environments (Google Colab, servers) may experience degraded performance or blocking due to anti-bot measures.

Some scrapers may work on a local machine but fail on remote servers, Linux CI, or GitHub Actions. This usually happens because of anti-bot protection, rate limits, geolocation differences, JavaScript rendering differences, or sudden source-side changes.

Usage

To run the scraper from the command line:

newswatch -k <keywords> -sd <start_date> -s [<scrapers>] -of <output_format> -v

Command-Line Arguments

Argument Description
-k, --keywords Required. Comma-separated keywords to scrape (e.g., "ojk,bank,npl")
-sd, --start_date Required. Start date in YYYY-MM-DD format (e.g., 2025-01-01)
-s, --scrapers Scrapers to use: specific names (e.g., "kompas,viva"), "auto" (default, platform-appropriate), or "all" (force all, may fail)
-of, --output_format Output format: csv, xlsx, or json (default: csv)
-o, --output_path Custom output file path (optional)
-v, --verbose Show detailed logging output (default: silent)
--list_scrapers List all supported scrapers and exit

Examples

# Basic usage
newswatch --keywords ihsg --start_date 2025-01-01

# Multiple keywords with specific scraper
newswatch -k "ihsg,bank" -s "tempo" --output_format xlsx -v

# List available scrapers
newswatch --list_scrapers

Python API Usage

import newswatch as nw

# Basic scraping - returns list of article dictionaries
articles = nw.scrape("ekonomi,politik", "2025-01-01")
print(f"Found {len(articles)} articles")

# Get results as pandas DataFrame for analysis
df = nw.scrape_to_dataframe("teknologi,startup", "2025-01-01")
print(df['source'].value_counts())

# Save directly to file
nw.scrape_to_file(
    keywords="bank,ihsg", 
    start_date="2025-01-01",
    output_path="financial_news.xlsx"
)

# Quick recent news
recent_news = nw.quick_scrape("politik", days_back=3)

# Get available news sources
sources = nw.list_scrapers()
print("Available sources:", sources)

See the comprehensive guide for detailed usage examples and advanced patterns. For interactive examples, see the API reference notebook.

Run on Google Colab

You can run news-watch on Google Colab Open In Colab

Output

The scraped articles are saved as a CSV, XLSX, or JSON file in the current working directory with the format news-watch-{keywords}-YYYYMMDD_HH.

The output file contains the following columns:

  • title
  • publish_date
  • author
  • content
  • keyword
  • category
  • source
  • link

Supported Websites (40)

Antara News, BBC News, Berita Jatim, Bisnis.com, Bloomberg Technoz, CNBC Indonesia, CNN Indonesia, Detik, Galamedia, IDN Times, iNews, Investor Daily, Jawapos, Jakarta Post, JPNN, Katadata, Kompas, Kontan, Kumparan, Liputan6, Media Indonesia, Merdeka, Metro TV News, Mongabay Indonesia, Okezone, Pikiran Rakyat, Poskota, Republika, RM.ID, RRI, SINDOnews, Suara, Suara Merdeka, Surabaya Pagi, Tempo, Tirto, Tribunnews, TVOne, TVRI News, Viva

Notes:

  • Use -s all to force-run all scrapers (may cause errors/timeouts).
  • Some sources are environment-sensitive and may fail on remote servers even if they work locally.
  • Limitation: Kontan scraper maximum 50 pages.

Contributing

Contributions are welcome! If you'd like to add support for more websites or improve the existing code, please open an issue or submit a pull request.

License

This project is licensed under the MIT License - see the LICENSE file for details. The authors assume no liability for misuse of this software.

Citation

DOI

@software{mabruri_newswatch,
  author = {Okky Mabruri},
  title = {news-watch},
  year = {2025},
  doi = {10.5281/zenodo.14908389}
}

Related Work

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

news_watch-0.7.0.tar.gz (72.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

news_watch-0.7.0-py3-none-any.whl (93.1 kB view details)

Uploaded Python 3

File details

Details for the file news_watch-0.7.0.tar.gz.

File metadata

  • Download URL: news_watch-0.7.0.tar.gz
  • Upload date:
  • Size: 72.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for news_watch-0.7.0.tar.gz
Algorithm Hash digest
SHA256 a6c5beed6dc0162363e79a4dbab1f1794bac18ee5ef3e62f9e88d0b63da06157
MD5 2a5c2ab8d850d7cc26cbba28ea9367e7
BLAKE2b-256 4560718ea9cb5b2d67e682ad031d1cb973d6a719a8fefdedb4a3570f9e959844

See more details on using hashes here.

Provenance

The following attestation bundles were made for news_watch-0.7.0.tar.gz:

Publisher: release.yml on okkymabruri/news-watch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file news_watch-0.7.0-py3-none-any.whl.

File metadata

  • Download URL: news_watch-0.7.0-py3-none-any.whl
  • Upload date:
  • Size: 93.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for news_watch-0.7.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9f45f1a4b4fad2405aca49dee839ec398758796ee6d9d0bc18e851377842b0d8
MD5 66bd2faaca163c4d381d4dd845467f3b
BLAKE2b-256 0152a18e69872d50e8c54bbfe227787e7e34a3e8ab37ff056494fc7100b4dc7f

See more details on using hashes here.

Provenance

The following attestation bundles were made for news_watch-0.7.0-py3-none-any.whl:

Publisher: release.yml on okkymabruri/news-watch

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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