Building a link preview is straightforward, but extracting the actual article content behind a URL is where the real engineering challenge begins. Arthur Junior, the developer behind GrabApe, recently shared a detailed breakdown of how he solved this problem for applications that need more than just metadata. While most tools grab page titles and images for social previews, Junior discovered that AI and reading applications require the full, readable text of a webpage, which is notoriously difficult to isolate from navigation, ads, and comments.
The Difference Between Metadata and Content
Junior explains that metadata extraction, which relies on Open Graph and Twitter Card tags, is relatively simple because websites explicitly provide this data for social platforms. However, metadata only describes what a page is about; it does not contain the article itself. For use cases like AI summarization, research tools, or offline reading modes, developers need the actual text. The challenge lies in the fact that a webpage is rarely structured around the article alone, often containing thousands of words of irrelevant content like sidebars, cookie notices, and user comments.
A Layered Extraction Strategy
To tackle the inconsistency of HTML structures across the web, Junior implemented a layered approach in GrabApe. The system first checks for structured article content in JSON-LD formats, specifically looking for the articleBody property. If that fails, it examines semantic HTML elements like and . As a fallback, the extractor utilizes the Readability library to identify main readable content. This multi-step process ensures that the application doesn't rely on a single, potentially fragile method to parse diverse websites.
Handling the Comment Section Problem
A major hurdle Junior encountered was distinguishing the main article from discussion sections. In one test case involving a DEV Community article, the initial extraction returned 6,876 words because it included the entire comment section nested within the article container. Junior avoided creating website-specific rules and instead improved the general discussion-region detection logic. By analyzing structural signals like comment-like HTML attributes and repeated user profile structures, the updated extractor successfully reduced the output to 2,755 words, retaining the main article while excluding the comments.
Practical API Implementation
Developers can implement similar functionality by using the GrabApe API, which distinguishes between successful, unavailable, and failed extraction outcomes. This distinction is crucial for robust applications, as an empty result shouldn't be assumed to be a successful extraction. The API allows users to request article content via a POST endpoint by including the article option in the request body. Junior emphasizes that a good extraction API must communicate when it cannot retrieve content, rather than failing silently or returning malformed data.
Key Takeaways
- Metadata extraction is for previews; article extraction is for processing content.
- A layered approach using JSON-LD, semantic HTML, and Readability improves reliability.
- Conservative pruning of discussion sections is better than aggressive, site-specific rules.
- APIs should return distinct status codes for success, unavailable, and failed extractions.
The Bottom Line
Stop assuming every tag contains only the article. Real-world web structures are messy, and robust extraction requires heuristics that respect ambiguous content rather than aggressively deleting it.