Giter Club home page Giter Club logo

warc-sqlite's Introduction

warc-sqlite

Simple demonstration of converting a set of warc.gz files into an indexed SQLite database. For context, see this discussion about WACZ: webrecorder/specs#62

Notes:

  • Data is stored by payload hash, so never stored twice
  • Headers are stored as one long string - this should be improved since it's redundant and not indexable
  • The only index there is right now allows querying by URL (exact or prefix)
    • for real use this would need to be expanded to search by other things such as request method, domain, ...
  • In theory the goal is for format conversion should be lossless - so it should be possible to convert the SQLite file back to WARC

Usage

To install:

pip install git+https://github.com/phiresky/warc-sqlite

To convert a directory containing warc.gz files (recursively):

warc-sqlite-import --db mydb.sqlite3 --input browsertrix/crawls/mycrawl

To get a list of urls (by a glob)

$ warc-sqlite-query --db mydb.sqlite3 --get_urls_like 'http://*example.com*'
http://example.com/
https://www.iana.org/domains/reserved
...

Get the raw payload of a url response

$ warc-sqlite-query --db mydb.sqlite3 --get_url_payload 'https://example.com'
<!doctype html>
<html>
<head>
    <title>Example Domain</title>

    <meta charset="utf-8" />
    <meta http-equiv="Content-type" content="text/html; charset=utf-8" />
    ...

doc:

usage: warc-sqlite-import --input [INPUT ...] [--allow_existing] --db DB [-h]

options:
  --input [INPUT ...]  (list[pathlib.Path], required) list of input paths. directory are
                       recursively searched
  --allow_existing     (bool, default=True) if true the import command is idempotent, if
                       false throw an error if an entry already exists
  --db DB              (Path, required) database file
  -h, --help           show this help message and exit
usage: warc-sqlite-query [--get_urls_like GET_URLS_LIKE] [--get_url_payload GET_URL_PAYLOAD] --db DB [-h]

options:
  --get_urls_like GET_URLS_LIKE
                        (Optional[str], default=None) print out a list of urls that match the given glob
  --get_url_payload GET_URL_PAYLOAD
                        (Optional[str], default=None) print the raw payload of the first response to an url to stdout
  --db DB               (Path, required) database file
  -h, --help            show this help message and exit

warc-sqlite's People

Contributors

celtic-coder avatar phiresky avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

warc-sqlite's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.