webmagic is a free, open source data extraction & web scraping project written in Java and released under Apache-2.0. It has 11,676 GitHub stars, 4,100 forks and 367 open issues, and was last pushed 9 months ago. On this registry it ranks #18 of 45 tracked projects in Data Extraction & Web Scraping, with 5 head-to-head comparisons available.

What is webmagic?

What it is

WebMagic is an open-source web crawler framework written in Java and released under the Apache 2.0 license. It lives in the Java ecosystem and is distributed through Maven Central as the us.codecraft:webmagic-core and us.codecraft:webmagic-extension artifacts. The project describes itself as a scalable crawler framework that covers the whole lifecycle of a crawler: downloading, URL management, content extraction, and persistence. Its architecture was written with reference to Scrapy, the Python crawler framework, and it has been maintained for roughly thirteen years, with the most recent push in December 2025.

The concrete problem it solves is the repetitive plumbing that every site-specific crawler otherwise requires. Rather than hand-writing fetch loops, retry logic, thread pools, and link scheduling for each target site, a developer implements a single PageProcessor interface and defines the extraction rules for that site. WebMagic then handles the surrounding machinery. The README frames the goal plainly: it can simplify the development of a specific crawler. Extraction itself is expressed through XPath, CSS-style selectors, regex, and link selectors, so the site-specific work stays declarative instead of becoming bespoke control flow.

Key capabilities

  • Full crawler lifecycle coverage: downloading, URL management, content extraction, and persistence are handled by the framework rather than by the caller.
  • A PageProcessor interface as the core extension point, with a Site object for per-crawler settings such as retry times and sleep time.
  • HTML extraction through a simple API, demonstrated with page.getHtml().xpath(...), page.getHtml().links().regex(...), and page.getUrl().regex(...).
  • Annotation-driven POJO crawlers using @TargetUrl, @HelpUrl, @ExtractBy, and @ExtractByUrl, which the README describes as requiring no configuration.
  • Multi-threaded execution, configured through the thread(5) call on the Spider builder.
  • Distribution support, listed alongside multi-threading as a framework feature.
  • Integration through Maven dependencies, with slf4j logging that can be swapped by excluding slf4j-log4j12.

Who uses it and how

  • Developers writing a site-specific crawler implement PageProcessor, add seed URLs, and run a Spider instance directly from a main method.
  • Teams that prefer declarative extraction define a POJO with annotation-based field mappings and run it through OOSpider with a page model pipeline.
  • Projects needing throughput configure multiple threads on the Spider builder, and the framework also lists distribution support for larger workloads.
  • Users wanting a management layer can adopt Gather Platform, a web console built on WebMagic for spider configuration and management.
  • New users can study the webmagic-samples package, which the README points to for additional examples.

Getting started

Add the webmagic-core and webmagic-extension dependencies to pom.xml, then either implement PageProcessor or annotate a POJO and run it through Spider or OOSpider. Documentation is hosted at webmagic.io/docs, and the README notes that slf4j-log4j12

project readme (upstream, from github) — read inline

logo

Readme in Chinese

Maven Central License Build Status

A scalable crawler framework. It covers the whole lifecycle of crawler: downloading, url management, content extraction and persistent. It can simplify the development of a specific crawler.

Features:

  • Simple core with high flexibility.
  • Simple API for html extracting.
  • Annotation with POJO to customize a crawler, no configuration.
  • Multi-thread and Distribution support.
  • Easy to be integrated.

Install:

Add dependencies to your pom.xml:

<dependency>
    <groupId>us.codecraft</groupId>
    <artifactId>webmagic-core</artifactId>
    <version>${webmagic.version}</version>
</dependency>
<dependency>
    <groupId>us.codecraft</groupId>
    <artifactId>webmagic-extension</artifactId>
    <version>${webmagic.version}</version>
</dependency>

WebMagic use slf4j with slf4j-log4j12 implementation. If you customized your slf4j implementation, please exclude slf4j-log4j12.

<exclusions>
    <exclusion>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
    </exclusion>
</exclusions>

Get Started:

First crawler:

Write a class implements PageProcessor. For example, I wrote a crawler of github repository information.

public class GithubRepoPageProcessor implements PageProcessor {

    private Site site = Site.me().setRetryTimes(3).setSleepTime(1000);

    @Override
    public void process(Page page) {
        page.addTargetRequests(page.getHtml().links().regex("(https://github\\.com/\\w+/\\w+)").all());
        page.putField("author", page.getUrl().regex("https://github\\.com/(\\w+)/.*").toString());
        page.putField("name", page.getHtml().xpath("//h1[@class='public']/strong/a/text()").toString());
        if (page.getResultItems().get("name")==null){
            //skip this page
            page.setSkip(true);
        }
        page.putField("readme", page.getHtml().xpath("//div[@id='readme']/tidyText()"));
    }

    @Override
    public Site getSite() {
        return site;
    }

    public static void main(String[] args) {
        Spider.create(new GithubRepoPageProcessor()).addUrl("https://github.com/code4craft").thread(5).run();
    }
}
  • page.addTargetRequests(links)

    Add urls for crawling.

You can also use annotation way:

@TargetUrl("https://github.com/\\w+/\\w+")
@HelpUrl("https://github.com/\\w+")
public class GithubRepo {

    @ExtractBy(value = "//h1[@class='public']/strong/a/text()", notNull = true)
    private String name;

    @ExtractByUrl("https://github\\.com/(\\w+)/.*")
    private String author;

    @ExtractBy("//div[@id='readme']/tidyText()")
    private String readme;

    public static void main(String[] args) {
        OOSpider.create(Site.me().setSleepTime(1000)
                , new ConsolePageModelPipeline(), GithubRepo.class)
                .addUrl("https://github.com/code4craft").thread(5).run();
    }
}

Docs and samples:

Documents: http://webmagic.io/docs/

The architecture of webmagic (referred to Scrapy)

image

There are more examples in webmagic-samples package.

License:

Licensed under Apache 2.0 license

Thanks:

To write webmagic, I refered to the projects below :

Mail-list:

https://groups.google.com/forum/#!forum/webmagic-java

http://list.qq.com/cgi-bin/qf_invite?id=023a01f505246785f77c5a5a9aff4e57ab20fcdde871e988

QQ Group: 373225642 542327088

Related Project

  • Gather Platform

    A web console based on WebMagic for Spider configuration and management.

Frequently asked questions

Is webmagic free to use?

webmagic is open source under the Apache-2.0 licence. There is no licence fee and no seat count — you can self-host it or, where the project offers one, pay a vendor for a managed version instead.

What does webmagic do?

A scalable web crawler framework for Java.

What is webmagic written in?

webmagic is primarily written in Java. Its source is publicly available at https://github.com/code4craft/webmagic, and it has 11,676 GitHub stars.