Skip to content
This repository has been archived by the owner on Apr 27, 2018. It is now read-only.

load a warc archive, filter it, and produce another warc archive #257

Open
dportabella opened this issue Oct 17, 2016 · 4 comments
Open

Comments

@dportabella
Copy link

We need to process a WARC archive, filter it based on keywords, and create a WARC archive. Something like this:

RecordLoader.loadArchives(in, sc)
  .keepValidPages()
  .filter(r => r.getContentString.contains("my keyword"))
  .saveAsWarcArchive("/path/out.warc.gz")

(saving request and response)

Is this possible with warc-base? if not, any idea on how to achieve it?

@lintool
Copy link
Owner

lintool commented Oct 17, 2016

This is not a use case we've considered thus far. Wouldn't be too hard to implement - loadArchive ultimately calls a Hadoop InputFormat to read ARCs and WARCs. We would need a corresponding Hadoop OutputFormat to implement the converse functionality. saveAsWarcArchive would then call this OutputFormat.

@ianmilligan1
Copy link
Collaborator

Just re-pinging this to keep it alive. I think I have a good use case for this too. Now to find time..

@dportabella
Copy link
Author

@lintool, with loadArchive returns a RDD[ArchiveRecord], so at this point we have lost the information on the request and response headers (except from url, date and mime type), right?

Of course, if we don't care about that headers, we can create a new archive with a dummy request and response headers. That would be ok for my current use case.

@dportabella
Copy link
Author

Hi,
I've created a gist to filter a WARC archive using Spark and storing the result back to a WARC archive:
https://gist.github.com/dportabella/3caf261c218a4448a03a14dbc06fe730

I did not created a sophisticated Spark writer/serializer, but it does the job.
If you are interested I can integrate this code to your warcbase project.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants