Sample-based XPath Ranking for Web Information Extraction

Oliver Jundt, Maurice van Keulen

Abstract

This paper presents an automated wrapper induction method that generates and ranks XPath expressions for web data extraction using a minimal set of examples. By leveraging fuzzy string similarity scores and aggregating results across multiple pages, the system identifies robust, generalized XPaths capable of handling layout variations. Experimental results on real-world bookstore data demonstrate that the system achieves high extraction accuracy with as few as 20–25 samples.

Introduction

Web information extraction typically relies on wrappers—scripts or configurations that define the precise location of target data (such as book titles or prices) within a webpage's HTML structure. Traditionally, these wrappers are created manually by developers who inspect the HTML and write specific extraction rules.

However, manual wrapper creation is difficult to scale. Scraping hundreds of different websites requires hundreds of unique wrappers, and any change in a site's layout can render a wrapper obsolete. To address this, the authors propose a system for automatic, on-the-fly wrapper induction, specifically targeting websites that follow the common "search result to detail page" pattern. The goal is to enable a system to "learn" extraction rules simply by being shown a few examples of the target data.

Methodology

The proposed "Sample-based XPath Ranking" pipeline follows a multi-step process to automate extraction:

  1. Input Data: The system receives a small set of samples, each consisting of an attribute (e.g., "Title: Moon Palace") and its corresponding detail page URL.
  2. Matching Score Calculation: The system traverses the XML/HTML tree of the page and compares the text content of every node against the sample attribute using the Jaro-Winkler string similarity algorithm. This fuzzy matching accounts for minor discrepancies like typos or capitalization differences.
  3. XPath Generation: For nodes that match the sample, the system generates candidate XPaths. A custom bottom-up algorithm balances specificity and generality, prioritizing unique id or class attributes as stable anchors.
  4. Ranking and Combination: To ensure robustness against outliers, the process is repeated for multiple sample pages. The scores for each candidate XPath are averaged across all samples, and the highest-ranked XPath is selected as the final extraction rule.
  5. Pruning: Specific XPaths are discarded if a more general version yields the same score, keeping the final wrappers clean and maintainable.
The sample-based XPath ranking pipeline, from individual attribute samples to a combined final ranking.

Experimental Setup

The researchers evaluated their approach using a real-world dataset from the online bookstore domain, encompassing 1,120 books across six providers: Amazon, Google Books, Bookdepository, Alibris, Abebooks, and Biblio. In total, 6,720 detail pages were processed. The system targeted seven specific attributes: Title, First Author, Publisher, Publication Year, Number of Pages, ISBN10, and ISBN13. To establish a "gold standard," attribute samples were initially pulled from Amazon using a manually verified wrapper.

Key Results and Insights

The most significant finding of the study is the identification of a "sweet spot" for sample size. As shown in the performance evaluations, extraction accuracy typically plateaus after 20 to 25 samples. This indicates that a very small amount of seed data is sufficient to build a robust wrapper that generalizes well across an entire site.

Mean similarity scores across different sample sizes for various provider-attribute pairs.

Other key insights include:

  • Fuzzy Matching Superiority: Using Jaro-Winkler similarity proved more effective than exact string matching, as it allowed the system to correctly identify attributes despite minor formatting differences (e.g., "The Lord of the Rings" vs. "The Lord of the Rings: Part 1").
  • Stability through Averaging: Averaging scores across different pages naturally filters out "lucky" XPaths that might work on a single page but fail on the site's general template.
  • High Accuracy: For providers with clean data like Amazon, the top-ranked XPath consistently achieved a perfect similarity score of 1.0.

Limitations and Future Work

Despite its success, the system faces challenges with granularity. If a sample is "345" (pages) but the HTML node contains "345 pages," the similarity score drops. Future work may involve "artificial insertion of nodes" to split text and improve matching. Additionally, the system currently struggles to distinguish between a "wrong path" and "missing data" when a provider does not list a specific attribute. The authors plan to explore probabilistic database approaches and alternative similarity measures, such as Levenshtein distance, to further refine extraction precision.

Summary updated

BibTeX
@inproceedings{jundt2013sample,
  author = {Oliver Jundt and Maurice van Keulen},
  title = {{Sample-based XPath Ranking for Web Information Extraction}},
  booktitle = {EUSFLAT Conf},
  year = {2013},
  doi = {10.2991/eusflat.2013.27},
}
Figure