-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from TeamHG-Memex/cdr
Export in CDRv2 format
- Loading branch information
Showing
4 changed files
with
71 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,44 @@ | ||
import scrapy | ||
|
||
|
||
class PageItem(scrapy.Item): | ||
url = scrapy.Field() | ||
text = scrapy.Field() | ||
is_page = scrapy.Field() | ||
depth = scrapy.Field() | ||
class CDRItem(scrapy.Item): | ||
|
||
def __repr__(self): | ||
return repr({ | ||
'url': self['url'], | ||
'is_page': self['is_page'], | ||
'depth': self['depth'], | ||
}) | ||
# (url)-(crawl timestamp), SHA-256 hashed, UPPERCASE (string) | ||
_id = scrapy.Field() | ||
|
||
# MIME type (multi (strings)) | ||
content_type = scrapy.Field() | ||
|
||
# Text label identifying the software used by the crawler (string) | ||
crawler = scrapy.Field() | ||
|
||
# Tika/other extraction output (object) | ||
# Our suff here: | ||
# forms: forms metadata as extracted by formasaurus | ||
# depth: page depth | ||
# is_page: this is a page reached by pagination | ||
extracted_metadata = scrapy.Field() | ||
|
||
# Tika/other extraction output (string) | ||
extracted_text = scrapy.Field() | ||
|
||
# Original source text/html (string) | ||
raw_content = scrapy.Field() | ||
|
||
class FormItem(scrapy.Item): | ||
# Text label identifying the team responsible for the crawler (string) | ||
team = scrapy.Field() | ||
|
||
# Timestamp of COLLECTION of data from the web (datetime) | ||
# https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-date-format.html#built-in-date-formats | ||
timestamp = scrapy.Field() | ||
|
||
# Full URL requested by the crawler (multi (strings)) | ||
url = scrapy.Field() | ||
form_type = scrapy.Field() | ||
|
||
# Schema version. This document describes schema version 2.0. (float) | ||
version = scrapy.Field() | ||
|
||
def __repr__(self): | ||
fields = ['_id', 'url', 'timestamp', 'extracted_metadata'] | ||
return '<CDRItem: {}>'.format(', '.join( | ||
'{}: {}'.format(f, repr(self[f])) for f in fields)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters