how to scrape news articles

For news scraping with Python, discover article URLs through official APIs, RSS feeds or sitemaps, fetch permitted pages, and extract their headlines, metadata and main text. Validate each result and remove duplicates before storing it.

Review each publisher’s terms and robots.txt before collection; see our web scraping legal guide for more detail.


Key Facts

  • Discover article URLs before attempting full-text extraction.
  • Keep discovery, fetching and extraction as separate stages.
  • HTTP 200 does not establish successful article extraction.
  • Store publication time separately from collection time.
  • Missing metadata should remain null rather than become an invented value.
  • Proxies route requests; they do not parse article text.

News scraping: how to scrape news articles step by step

A news scraping pipeline turns discovered article URLs into validated records. Use a 4-stage article collection model: discover, fetch, extract and validate.

  • Discover: Build a queue from an official publisher API, RSS feeds, sitemaps or section pages.
  • Fetch: Request each permitted article and record its status, final URL and collection time.
  • Extract: Separate the headline, author, publication date and body from navigation, advertisements and related stories.
  • Validate: Check completeness, resolve duplicate records and export accepted articles.

For each URL, log the last completed stage and any error so you can distinguish discovery, fetching, extraction and validation failures.

News scraping in 4 steps


How do you find article URLs for news scraping with APIs, RSS and sitemaps?

For news scraping across websites, prefer official publisher APIs or RSS feeds, then sitemaps. Use section-page links when those discovery sources do not cover the articles you need.

Step 1: Check the publisher’s official API. For Guardian coverage, start with the Guardian Open Platform documentation. Check whether the available fields and usage terms fit your collection before fetching article pages separately.

Step 2: Read RSS feeds. Collect article links when present. Retain available entry identifiers, titles and timestamps as discovery metadata; store missing values as null and skip entries without a usable article URL. These fields are optional in the RSS 2.0 specification. Inspect whether entries contain summaries or complete text; do not assume a feed description is the article body. Our guide to parsing XML and RSS feeds in Python covers this input format.

Step 3: Process sitemaps. Follow relevant sitemap indexes and queue article URLs. Treat sitemap modification dates as discovery hints rather than publication dates.

Step 4: Inspect section pages. Resolve relative links, restrict collection to intended publisher domains and deduplicate the queue. Put a stopping condition on pagination, such as reaching the requested date range or finding no new article URLs.

Extract each article separately. Running a body extractor on a section page risks combining headlines and summaries from unrelated stories.


Should you choose a news API, extraction API or Python library?

Choose discovery tools for finding stories and extraction tools for turning article pages into structured text. Whether a service returns full text must be checked separately from whether it returns article URLs.

Full-text limitation: NewsAPI search results do not include complete article content (as of November 2026). Its official full-content documentation describes fetching the article URL and extracting its text as separate steps.

Approach Use it when… Avoid it when…
Publisher or news API Use an API when its coverage, fields and usage terms match your task. Avoid relying on it for complete bodies when the documented response excludes them.
Extraction API Use an extraction API when you want a hosted extraction workflow and have checked its output. Avoid committing before checking retention terms, failure handling and total cost.
Selector-based parser Use selectors when you maintain a small set of known page templates. Avoid assuming one selector will work across unrelated publishers.
Article extraction library Use an article extractor when you need a starting point across varied layouts. Avoid accepting its output without checking missing paragraphs and boilerplate.

Competitor data: taken from each provider’s official pricing and documentation pages linked in this article, collected on November 10, 2026.

For local Python extraction, Beautiful Soup documents HTML traversal and CSS selectors. Trafilatura documents main-text extraction and metadata output. Beautiful Soup suits explicit template rules; Trafilatura supplies the newspaper-style body extraction used in the example below.


What article fields should you collect?

Collect the headline, author, publication date, body text and source, together with URLs and collection metadata. Keep missing values explicit so downstream systems can distinguish absence from extraction failure.

Field Meaning Validation
headline The article’s title Check against the visible article heading.
author The published byline Keep null when no byline is available.
published_at The publication date or timestamp Do not substitute a modification or collection date.
body The article’s main text Check opening, middle and final paragraphs.
source The publisher or source domain Use one consistent naming convention.
requested_url, fetched_url The input URL and final response URL Retain redirects for troubleshooting.
canonical_url The publisher’s preferred article URL, when identified Validate before using it as a duplicate key.
collected_at The collection timestamp in UTC Keep separate from editorial timestamps.

Preserve date precision: a date without a time zone is not an exact UTC timestamp. Store extraction status and error details alongside the article record, rather than inserting error messages into the body.


How do you build a Python news scraper?

Fetch one permitted article, pass its HTML to an article extractor, and map the result into your schema. Start with a single URL so you can inspect the output before adding a queue.

Example: Markup changes can alter extraction results, and nonempty text is only an initial check.

Install the dependencies using the Requests quickstart and Trafilatura installation instructions:

python -m pip install requests trafilatura

Use Python 3.10 or later. Save the following code as news_scraper.py, run python news_scraper.py in a terminal, and enter the article URL when prompted.

import json
from datetime import datetime, timezone
from urllib.parse import urlsplit

import requests
import trafilatura

url = input("Permitted article URL: ").strip()
response = requests.get(url, timeout=(10, 30))
response.raise_for_status()
if "html" not in response.headers.get("Content-Type", "").lower():
    raise ValueError("Expected an HTML article")

raw = trafilatura.extract(
    response.content, url=response.url,
    output_format="json", with_metadata=True,
    include_comments=False,
)
data = json.loads(raw) if raw else {}
if not (data.get("text") or "").strip():
    raise ValueError("No article body extracted")

record = {
    "headline": data.get("title"),
    "author": data.get("author"),
    "published_at": None,
    "extracted_date_candidate": data.get("date"),
    "date_validation_status": "unverified",
    "body": data["text"],
    "source": urlsplit(response.url).hostname,
    "requested_url": url,
    "fetched_url": response.url,
    "collected_at": datetime.now(timezone.utc).isoformat(),
}
print(json.dumps(record, ensure_ascii=False))

The extracted date is a candidate, not a verified publication date. Populate published_at only after checking explicit publication metadata or the article’s publication label. Trafilatura’s metadata extraction uses htmldate, whose date extraction code can retain a modification date as a fallback.

The example stops on HTTP errors or an empty body. It does not implement discovery, retry scheduling, canonical-link validation or quality scoring.

An illustrative record fragment, not a measured extraction result:

{
  "headline": "Example news headline",
  "author": null,
  "published_at": null,
  "body": "Example article text.",
  "source": "example.com"
}

Do you need a headless browser?

You need browser rendering when the permitted article text depends on JavaScript and is absent from the initial HTML. If the response already contains the complete body, begin with an ordinary HTTP request.

Compare the fetched HTML with the visible article before changing tools. Missing extracted text can also mean a broken selector, an unsuitable extraction rule, a consent page or a truncated response.

When rendering is necessary, wait for an article-specific element and validate the resulting text. A browser cannot establish permission to collect content. Respect paywalls and login restrictions; do not use rendering or proxies to bypass them.


How do you clean, deduplicate and export articles?

Normalize whitespace, preserve paragraph boundaries and deduplicate using both article identity and text. Keep the original URLs so every accepted record remains traceable.

  • Clean carefully: Remove repeated navigation, subscription prompts and related-story text without deleting captions or meaningful article sections automatically.
  • Validate canonical URLs: Resolve relative values and inspect unexpected domain changes before merging records.
  • Normalize URLs conservatively: Remove known tracking parameters, but retain parameters that change the article or edition.
  • Detect exact duplicates: Hash normalized body text to identify matching bodies under different URLs.
  • Preserve updates: A changed body under the same URL may be an editorial revision. Keep its collection time and version rather than silently overwriting it.

Use JSON Lines for incremental records, or a database when you need updates and duplicate constraints. Export CSV only with proper quoting for multiline bodies. Similar headlines alone are insufficient evidence that two articles are duplicates.


How do you handle failures, rate limits and proxy sessions?

Set explicit timeouts, bound retries and slow collection when a publisher signals overload. Keep network failures separate from extraction failures so retrying does not conceal a parser problem.

The example’s Requests timeout tuple sets connection and read timeouts; it is not a total download deadline (as of November 2026). See the official timeout documentation.

  • Timeouts and transient server failures: Use a small retry budget, increasing delays and a per-publisher concurrency limit. Record exhausted attempts.
  • HTTP 429: Pause requests to that publisher and reduce the request rate. The HTTP 429 specification describes this rate-limit response.
  • Retry-After: Honor the delay when present; HTTP Semantics defines either a delay in seconds or an HTTP date.
  • Access denials or challenges: Stop and review access conditions instead of repeatedly changing IPs.
  • HTTP 200 with unusable text: Investigate the returned page and extraction rules before fetching again.

Proxy boundary: Proxies route requests; they do not parse articles. DataImpulse is our proxy product.

For permitted collection requiring a particular country, our residential proxies include free country targeting and support rotating or sticky sessions. Use a sticky session when a multi-request workflow needs continuity. Neither session mode promises access.

Our datacenter proxies are another routing option to evaluate for your target. Choose using your access requirements and observed responses; our proxy selection guide covers further considerations.


How do you test extraction quality before scaling?

HTTP 200 does not establish successful article extraction. Check body completeness, metadata accuracy and unwanted navigation text before increasing collection volume.

A practical evaluation plan is to select 30 permitted public articles across three publishers and compare Beautiful Soup selectors with Trafilatura on identical saved HTML. This is a proposed evaluation, not a completed test or a performance claim.

  • Body completeness: Manually compare the extracted opening, middle and ending with the article. Record missing paragraphs and truncation.
  • Boilerplate: Record navigation, advertisements, subscription prompts and unrelated stories mixed into the body.
  • Metadata: Check headline, byline and publication date independently. Distinguish missing source metadata from extraction mistakes.
  • Fetching: Separately record request failures, latency and response-body bytes. Define whether byte counts measure decoded content or network transfer.

Publish the evaluation date, article URLs, dependency versions, scoring rubric, sample size and failures with any results. Describe the findings as a snapshot of those pages and versions, not a benchmark for all publishers.

Retain representative permitted HTML samples for regression checks. Recheck them after extraction changes, and investigate sudden shifts in empty bodies or missing metadata.


Frequently Asked Questions


Frequently Asked Questions

What is news scraping?

News scraping converts article pages into structured records for tasks such as media monitoring or research. A useful record includes the article text, its source URL and enough metadata to trace when and where it was collected.

Can I collect news articles through RSS alone?

Inspect the actual feed entries before deciding. If they contain only summaries, use their article links for permitted full-text collection; keep feed metadata separate from metadata extracted from the article.

Why does my scraper return menus instead of article text?

A parser may be selecting the entire page or the wrong container. Inspect the returned HTML, narrow the extraction target and check whether the article body is actually present before adding browser rendering.

How should I handle missing authors or publication dates?

Keep missing fields null and attach a validation status. Do not infer an author from the publisher name or turn the collection timestamp into a publication date.

Public visibility alone does not settle whether collection or reuse is permitted. Check the publisher’s access and reuse conditions, respect paywalls, and assess your intended use under the applicable rules.

Do I need a proxy for a small news scraper?

Start by assessing whether your permitted workflow needs an alternate route or country-specific view. A proxy adds routing capability, but extraction rules, request pacing and content validation remain your responsibility.

How much does news scraping cost?

Budget for requests, any browser rendering, extraction, storage and maintenance. If you use paid proxy traffic, measure actual bytes and failed attempts on a small permitted sample before estimating a larger collection.


Add proxy routing when your collection needs it

If your validated workflow needs country-specific routing, consider DataImpulse residential proxies from $1 per GB, with non-expiring traffic, 90M+ residential IPs and coverage across 195+ countries. New customers can start with a one-time $5 Intro plan; subsequent top-ups start at $50.

Begin with a small permitted sample and check the extracted articles before expanding collection.

Last updated: November 10, 2026.