How Shortcuts Uses Safari Reader Without Opening Windows
This article explains how the "Get Article using Safari Reader" action in Apple’s Shortcuts app extracts clean text and metadata from URLs entirely in the background. By utilizing headless system frameworks, background networking, and WebKit's content-scoring algorithms, Shortcuts can process a list of web links, strip away advertisements and navigation clutter, and output structured article data without ever launching a visible Safari browser window.
Background Network Requests
When you pass a list of URLs into the "Get Article using Safari
Reader" action, the Shortcuts app does not send these links to the
Safari application. Instead, Shortcuts initiates asynchronous background
network requests using Apple’s native URLSession API. This
downloads the raw HTML source code of each webpage directly into the
device's memory, bypassing the need to load visual assets like heavy
stylesheets, third-party tracking scripts, or media files.
Headless WebKit Processing
To turn raw HTML into a readable structure, the system relies on WebKit, the underlying browser engine that powers Safari. Rather than launching the full Safari user interface, Shortcuts spins up an invisible, "headless" instance of WebKit in the background.
This headless parser constructs the Document Object Model (DOM)—a structural tree of the webpage's code—entirely in memory. Because the system does not have to calculate pixel layouts, render fonts, or draw a window on your screen, it can process a batch of URLs rapidly and with minimal battery or CPU impact.
The Safari Reader Scoring Algorithm
Once the DOM is built in the background, the system applies the Safari Reader extraction algorithm. This engine analyzes the structure of the webpage to separate the core article from the surrounding clutter. It does this through a point-based heuristics system:
- Tag Evaluation: It looks for semantic HTML5 tags
like
<article>and<main>, immediately giving them a high probability score of containing the body text. - Text Density: It measures the length of paragraphs
(
<p>tags) and counts the number of commas and sentences. Blocks of code with dense, continuous text are scored positively. - Link Density: It calculates the ratio of linked text to normal text within a container. High link density indicates a navigation bar, sidebar, or "related articles" footer, which are scored negatively and stripped away.
- Class and ID Inspection: It scans the code for developer labels. Elements labeled with words like "comment," "ad," "promo," or "sidebar" are deleted, while labels like "post," "entry," or "body" are preserved.
The highest-scoring cluster of nodes is isolated as the clean article body, while everything else is discarded.
Metadata Extraction
While isolating the body text, the parser simultaneously scans the
<head> and <article> sections of
the HTML to extract specific metadata. It extracts the author,
publication date, title, and main image URL by looking at standardized
web protocols in a specific order of priority:
- JSON-LD and Schema.org: Structured data scripts embedded by publishers specifically for search engines.
- Open Graph and Twitter Cards:
<meta>tags (such asog:titleorarticle:published_time) used to generate rich link previews on social media. - Standard HTML Tags: Fallback tags like the standard
<title>element,<time>tags, and byline classes (e.g.,rel="author").
Mapping to the Shortcuts Content Graph
After the text and metadata are extracted, the background process terminates the headless WebKit instance and hands the purified data over to the Shortcuts Content Graph. The Content Graph converts the raw data into a native "Article" object.
Because the data is now structured natively within Shortcuts, you can easily tap on the magic variable output of the action and choose to pass only the Body (as rich text, HTML, or plain text), the Author, the Published Date, or the Excerpt to the next action in your automation.