MCPcopy Index your code
hub / github.com/centic9/CommonCrawlDocumentDownload

github.com/centic9/CommonCrawlDocumentDownload @1.0.0.11

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.0.0.11 ↗ · + Follow
139 symbols 352 edges 30 files 39 documented · 28% updated 11d ago1.0.0.11 · 2025-11-10★ 74
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Build Status Gradle Status Release GitHub release Tag Maven Central Maven Central

This is a small tool to find matching URLs and download the corresponding binary data from the CommonCrawl indexes.

Support for the newer URL Index (http://blog.commoncrawl.org/2015/04/announcing-the-common-crawl-index/) is available, older URL Index as described at https://github.com/trivio/common_crawl_index and http://blog.commoncrawl.org/2013/01/common-crawl-url-index/ is still available in the "oldindex" package.

Please note that a full run usually finds a huge number of files and thus downloading will require a large amount of time and lots of disk-space if the data is stored locally!

NOTE This project does not implement backoff on HTTP errors about too many requests. Due to the current high rate of access by many GPT/LLM experiments, the CommonCrawl S3 bucket very often returns HTTP errors about rate exceeded. See https://github.com/tballison/commoncrawl-fetcher-lite for a newer implementation of this with more advanced functionality that work more reliably.

NOTE: CommonCrawl only stores up to 1MB per file and cuts off any bytes exceeding this length. So larger documents will be truncated and might not be valid and parsable any more. You can try to download the original file via the URL that is part of the crawl-data, but this project does not implement this due to potential "crawling" restrictions on target websites.

Getting started

Grab it

git clone https://github.com/centic9/CommonCrawlDocumentDownload.git

Build it and create the distribution files

cd CommonCrawlDocumentDownload
./gradlew check

Run it

Fetch a list of interesting documents

./gradlew lookupURLs

Reads the current Common Crawl URL index data and extracts all URLs for interesting mime-types or file extensions, stores the URLs in a file called commoncrawl-CC-MAIN-<year>-<crawl>.txt

Download documents

./gradlew downloadDocuments

Uses the URLs listed in commoncrawl-CC-MAIN-<year>-<crawl>.txt to download the documents from the Common Crawl

Deduplicate files

./gradlew deduplicate

Some files have equal content, this task will detect these based on file-size and content-hash and move all duplicates to a backup-directory to leave only unique files in place.

Deprecated: Download documents from the old-index

./gradlew downloadOldIndex

Starts downloading the URL index files from the old index and looks at each URL, downloading binary data from the common crawl archives.

The longer stuff

Change it

Run unit tests

./gradlew check jacocoTestReport

Adjust which files are found

There are a few things that you can tweak:

  • The file-extensions that are detected as download-able files are handled in the class Extensions.
  • The mime-types that are detected as download-able files isare handled in the class MimeTypes.
  • Adjust the name of the list of found files in DownloadURLIndex.COMMON_CRAWL_FILE.
  • Adjust the location where files are downloaded to in Utils.DOWNLOAD_DIR.
  • The starting file-index (of the approximately 300 cdx-files) is currently set as constant in class org.dstadler.commoncrawl.index.DownloadURLIndex, this way you can also re-start a download that was interrupted before.

Adjust which commoncrawl-index is fetched

CommonCrawl periodically runs crawls and publishes them. You can switch to newer crawls by adjusting the constant CURRENT_CRAWL in DownloadURLIndex.java to the proper <year>-<week> number of the newer crawl.

See https://commoncrawl.org/connect/blog/ for announcemnts of the latest crawls.

Ideas

  • Old Index: By adding a new implementation of BlockProcesser (likely re-using existing stuff by deriving from one of the available implementations), you can do things like streaming processing of the file instead of storing the file locally, which will avoid using too much disk-space

Estimates (based on Old Index)

  • Size of overall URL Index is 233689120776, i.e. 217GB
  • Header: 6 Bytes
  • Index-Blocks: 2644
  • Block-Size: 65536
  • => Data-Blocks: 3563169
  • Aprox. Files per Block: 2.421275
  • Resulint aprox. number of files: 8627412
  • Avg. size per file: 221613
  • Needed storage: 1911954989425 bytes = 1.7TB!

Related projects/pages

  • http://commoncrawl.org/
  • http://commoncrawl.org/the-data/examples/
  • https://github.com/trivio/common_crawl_index
  • https://github.com/wiseman/common_crawl_index
  • https://github.com/ikreymer/cc-index-server
  • https://github.com/ikreymer/webarchive-indexing
  • https://github.com/ikreymer/cdx-index-client
  • https://github.com/internetarchive/webarchive-commons
  • https://github.com/iipc/webarchive-commons
  • https://github.com/ikreymer/pywb
  • http://decalage.info/download_mso_files

Release it

  • Check the version defined in gradle.properties
  • Push changes to GitHub
  • Publish the binaries to Maven Central

    ./gradlew --console=plain publishToMavenCentral

  • This should automatically release the new version on MavenCentral

  • Apply tag in Github (git tag && git push --tags)
  • Increase the version in gradle.properties afterwards
  • Afterwards go to the Github tags page and create a release and add release-notes for the published version
  • The resulting binaries should appear at https://repo1.maven.org/maven2/org/dstadler/CommonCrawlDocumentDownload/

Support this project

If you find this library useful and would like to support it, you can Sponsor the author

Licensing

Extension points exported contracts — how you extend this code

BlockProcessor (Interface)
Interface for handling one block of data from the Common Crawl URL index. @author dominik.stadler [3 implementers]
src/main/java/org/dstadler/commoncrawl/oldindex/BlockProcessor.java

Core symbols most depended-on inside this repo

toExtension
called by 38
src/main/java/org/dstadler/commoncrawl/MimeTypes.java
matches
called by 37
src/main/java/org/dstadler/commoncrawl/MimeTypes.java
computeDownloadFileName
called by 20
src/main/java/org/dstadler/commoncrawl/Utils.java
matches
called by 14
src/main/java/org/dstadler/commoncrawl/Extensions.java
convertUrl
called by 13
src/main/java/org/dstadler/commoncrawl/Utils.java
isCorruptDownload
called by 11
src/main/java/org/dstadler/commoncrawl/Utils.java
reverseDomain
called by 10
src/main/java/org/dstadler/commoncrawl/Utils.java
toString
called by 8
src/main/java/org/commoncrawl/hadoop/mapred/ArcRecord.java

Shape

Method 107
Class 31
Interface 1

Languages

Java100%

Modules by API surface

src/main/java/org/commoncrawl/hadoop/mapred/ArcRecord.java25 symbols
src/main/java/org/dstadler/commoncrawl/oldindex/ProcessImpl.java10 symbols
src/main/java/org/dstadler/commoncrawl/Utils.java9 symbols
src/test/java/org/dstadler/commoncrawl/UtilsTest.java8 symbols
src/test/java/org/dstadler/commoncrawl/index/DownloadFromCommonCrawlTest.java6 symbols
src/main/java/org/dstadler/commoncrawl/Deduplicate.java6 symbols
src/main/java/org/dstadler/commoncrawl/index/DownloadURLIndex.java5 symbols
src/main/java/org/dstadler/commoncrawl/Download.java5 symbols
src/main/java/org/dstadler/commoncrawl/DocumentLocation.java5 symbols
src/test/java/org/dstadler/commoncrawl/oldindex/OldIndexUtilsTest.java4 symbols
src/test/java/org/dstadler/commoncrawl/index/DownloadURLIndexTest.java4 symbols
src/test/java/org/dstadler/commoncrawl/DocumentLocationTest.java4 symbols

For agents

$ claude mcp add CommonCrawlDocumentDownload \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact