News crawling with StormCrawler - stores content as WARC
News crawling with StormCrawler - stores content as WARC
Crawler for news based on StormCrawler. Produces WARC files to be stored as part of the Common Crawl. The data is hosted as AWS Open Data Set – if you want to use the data and not the crawler software please read the announcement of the news dataset.
The project is a custom Apache StormCrawler topology. Stock StormCrawler provides the heavy machinery — the HTTP fetcher, robots.txt handling, URL partitioner, WARC writer and OpenSearch status index. This repository adds ~10 news-specific bolts and filters on top (parsing Google News sitemaps, detecting RSS/Atom feeds, news-aware URL filtering).
Two indexes / stores are involved:
DISCOVERED, FETCHED, REDIRECTION, ERROR). This is the crawler's memory of what to fetch next.warc.dir) hold the actual fetched content — this is the output shipped to Common Crawl.The production crawl is a Storm pipeline defined primarily in conf/crawler.flux (the main topology, launched via Storm Flux). A functionally-equivalent Java implementation of the same pipeline is provided in CrawlTopology. Either way the DAG is the same:
seeds/feeds.txt
→ FileSpout → PreFilterBolt → URLPartitionerBolt → FetcherBolt
→ {NewsSiteMapParserBolt, FeedParserBolt} (extract article links)
→ WARCHdfsBolt (write content to WARC on disk)
+ StatusUpdaterBolt (write URL states to OpenSearch)Feeds and sitemaps are re-fetched on a schedule to discover new articles; the article URLs they yield are queued in the status index and fetched in turn.
Alternatively, use the Docker Compose setup, see below.
The crawler relies on RSS/Atom feeds and news sitemaps to find links to news articles on news sites. A small collection of example seeds (feeds and sitemaps) is provided in ./seeds/. Adding support for news sites which do not provide a news feed or sitemap is an open issue, see #41.
The default configuration works out-of-the-box for a local test crawl. The only mandatory change is the HTTP user agent — news sites reject requests without a real User-Agent. Open conf/crawler-conf.yaml and fill in http.agent.name and the other http.agent.* properties (version, url, email).
The crawl is configured through a handful of files under conf/, layered on top of StormCrawler's built-in crawler-default.yaml (later files override earlier ones):
| File | What it configures |
|---|---|
crawler-conf.yaml |
Main crawler config: HTTP agent (http.agent.*), fetch parallelism, timeouts, content-size limits, and the warc.* keys (warc.dir, warc.rotation.policy.max-mb / max-minutes). |
opensearch-conf.yaml |
OpenSearch cluster addresses and the status-index / indexer settings. |
crawler.flux |
The main topology definition itself (spouts, bolts, streams) and the WARC output settings — see below. Includes the two files above. |
bootstrap-conf.yaml |
Config for the bootstrap topology; sets a distinct WARC directory (/data/warc/bootstrap) and a more conservative fetcher.server.delay. |
Where WARC files are written and how they rotate is configured differently depending on which topology you launch:
crawler.flux) — hardcoded in the component definitions. The output path is WARCFileNameFormat.withPath("/data/warc") and rotation is 1024 MB / 1440 minutes in WARCFileRotationPolicy. These ignore the warc.* config keys, so to change them you must edit crawler.flux directly. Also fill in the placeholder WARCInfo header values (http-header-user-agent, http-header-from, operator, robots), which ship as "...".CrawlTopology) — read from config. The output path comes from warc.dir (default /data/warc) and rotation from warc.rotation.policy.max-mb / warc.rotation.policy.max-minutes in crawler-conf.yaml; the WARC header fields are derived from the http.agent.* values at runtime.In both cases the WARC output directory must exist before you start the crawl.
Once the configuration is in place, generate the uberjar:
mvn clean packageThe main news crawler topology is defined in conf/crawler.flux and launched via Storm Flux — this is also the default entry point of the shaded jar (its manifest mainClass is org.apache.storm.flux.Flux).
For a quick local smoke test you can instead run the equivalent Java topology CrawlTopology in local mode. Note the -- separator: it overrides the manifest's default Flux main class so the named class runs instead.
storm local target/crawler-3.7.0.jar --local-ttl 60 -- org.commoncrawl.stormcrawler.news.CrawlTopology -conf $PWD/conf/opensearch-conf.yaml -conf $PWD/conf/crawler-conf.yaml $PWD/seeds/ feeds.txtThis will launch the crawl topology in local mode for 60 seconds. It will also "inject" all URLs found in the file ./seeds/feeds.txt in the status index. The URLs point to news feeds and sitemaps from which links to news articles are extracted and fetched. The topology will create WARC files in the directory specified in the configuration under the key warc.dir. This directory must be created beforehand.
Of course, it's also possible to add (or remove) the seeds (feeds and sitemaps) using the OpenSearch API. In this case, the topology can be run without the last two arguments.
In production, you should use storm jar ... to run the topology in distributed mode and continuously (no time limit) including the Storm UI and logging (see the Docker Compose section below for the exact Flux and Java commands).
The news crawl assumes its seeds are already known to be feeds or news sitemaps. When you only have a list of candidate URLs (e.g. news site home pages) and don't yet know which of them expose a feed or a Google News sitemap, run the bootstrap topology first.
BootstrapTopology reuses the same fetch skeleton but replaces the parser bolts with detector bolts — NewsSiteMapDetectorBolt and FeedDetectorBolt — which classify a fetched URL by its content/Content-Type instead of extracting article links from it. The detected feeds and sitemaps can then be used as seeds for the production crawl above.
It uses its own configuration (conf/bootstrap-conf.yaml), which sets a distinct WARC output directory and a more conservative fetcher.server.delay. Run it like the production topology, but with the bootstrap main class and config:
storm local target/crawler-3.7.0.jar --local-ttl 60 -- org.commoncrawl.stormcrawler.news.bootstrap.BootstrapTopology -conf $PWD/conf/opensearch-conf.yaml -conf $PWD/conf/bootstrap-conf.yaml $PWD/seeds/ feeds.txtWhen the topology is running you can check that URLs have been injected and news are getting fetched on . Or use StormCrawler's OpenSearch dashboards to monitor the crawling process on .
There is also a shell script bin/status to get aggregated counts from the status index, and to add, delete or force a re-fetch of URLs. E.g.,
$> bin/status aggregate_status
3824 DISCOVERED
34 FETCHED
5 REDIRECTIONRun bin/status without arguments to see the full list of sub-commands (each sub-command is a function inside the script). Pass -C to colorize the JSON output.
Do not forget to create the uberjar (see above) which is included in the Docker image. Simply run:
mvn clean packageVerify the configuration in the file docker-compose.yaml and conf/ is correct:
fast.urlfilter.file: "s3://..." in conf/) the worker needs AWS credentials.Then download and build the Docker images:
docker compose -f docker-compose.yaml up --build --renew-anon-volumes --remove-orphansWait until the containers are running, then initialize the OpenSearch index and the dashboards:
./bin/OS_IndexInit.sh
./bin/dashboards/OS_ImportDashboards.shNOTE:
Submit the topology from the news-crawler service. The main path uses Storm Flux with conf/crawler.flux:
docker compose run --rm news-crawler \
storm jar lib/crawler.jar org.apache.storm.flux.Flux --remote /news-crawler/conf/crawler.fluxOr run the equivalent Java topology (the -- separator overrides the manifest's default Flux main class):
docker compose run --rm news-crawler \
storm jar lib/crawler.jar -- org.commoncrawl.stormcrawler.news.CrawlTopology \
/data/seeds '*' -conf conf/opensearch-conf.yaml -conf conf/crawler-conf.yamlAfter 1-2 minutes if everything is up, connect to OpenSearch on port 9200 or the OpenSearch dashboards on port 5601.
For inspecting the worker log files (the container name matches container_name: for the storm-supervisor service in docker-compose.yaml):
docker exec storm-supervisor-news-crawl /bin/bash -c 'cat /logs/workers-artifacts/*/*/worker.log'To stop the topology:
docker compose run --rm -ti news-crawler /bin/bash
$> storm list
Topology_name Status Num_tasks Num_workers Uptime_secs Topology_Id Owner
----------------------------------------------------------------------------------------
NewsCrawl ACTIVE 48 1 146 NewsCrawl-1-1774977605 storm
$> storm kill NewsCrawlRequires JDK 17+ (see .java-version). Common commands:
mvn clean package # build the shaded uberjar → target/crawler-3.7.0.jar
mvn test # run all JUnit tests
mvn test -Dtest=NewsSiteMapParserTest # run a single test classCode style is google-java-format (AOSP profile), enforced in CI by the Cosium
No open issues yet, or sync has not completed.