Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/ranking #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions services/service-crawler/webcrawler/spiders/news_de_DE.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,15 @@

class NewsSpider(scrapy.Spider):
name = "news_de_DE"
allowed_domains = [
'spiegel.de',
'tagesschau.de',
'wdr.de',
'kindersache.de',
'zdf.de',
'faz.net'
]

start_urls = [
'http://www.spiegel.de/',
'https://www.tagesschau.de/',
Expand All @@ -16,15 +25,6 @@ class NewsSpider(scrapy.Spider):
'https://www.faz.net/aktuell/'
]

trustedUrls = [
'http://www.spiegel.de/',
'https://www.tagesschau.de/',
'https://www1.wdr.de/',
'https://www.kindersache.de/',
'https://www.zdf.de/nachrichten',
'https://www.faz.net/aktuell/'
]

def parse(self, response):
url = response.url
for data in response.css('html'):
Expand Down
61 changes: 32 additions & 29 deletions services/service-crawler/webcrawler/spiders/news_en_EN.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,30 @@

class NewsSpider(scrapy.Spider):
name = "news_en_EN"
start_urls = [
'https://www.theguardian.com/', #new
'https://www.firstnews.co.uk/', #news for children
'https://www.bbc.com/', 'https://www.bbc.co.uk/', #news
'https://www.bbc.co.uk/newsround', #news for children
'http://www.bbc.co.uk/learningenglish/english/', #BBC ESL site
'http://www.worldofwanderlust.com/', #travel blog
'http://hannahgale.co.uk/', #livestyle blow
'https://www.thewanderblogger.com/' #expat livestyle blog
allowed_domains = [
'theguardian.com',
'bbc.com',
'bbc.co.uk',
'worldofwanderlust.com',
'hannahgale.co.uk',
'thewanderblogger.com'
]

trustedUrls = [
'https://www.theguardian.com/', #new
'https://www.firstnews.co.uk/', #news for children
'https://www.bbc.com/', 'https://www.bbc.co.uk/', #news
'http://www.worldofwanderlust.com/', #travel blog
'http://hannahgale.co.uk/', #livestyle blow
'https://www.thewanderblogger.com/' #expat livestyle blog
start_urls = [
'https://www.bbc.com/news/world-europe-48417744', #testing article, DONT DELETE
'https://www.theguardian.com', #news
'https://www.bbc.com',
'https://www.bbc.co.uk', #news
'https://www.bbc.co.uk/newsround', #news for children
'http://www.bbc.co.uk/learningenglish/english', #BBC ESL site
'http://www.worldofwanderlust.com', #travel blog
'http://hannahgale.co.uk', #livestyle blow
'https://www.thewanderblogger.com' #expat livestyle blog
]

def parse(self, response):


url = response.url
for data in response.css('html'):

Expand All @@ -36,17 +39,17 @@ def parse(self, response):

# preprocess text for lowercase search and normalized data
text = " ".join(str(element) for element in data.css('p::text').getall())
preprocessedText = textacy.preprocess_text(
text,
no_accents=True,
no_punct=True,
lowercase=True,
fix_unicode=True,
no_emails=True,
no_phone_numbers=True,
no_contractions=True
)
preprocessedText = textacy.preprocess.normalize_whitespace(preprocessedText)
# preprocessedText = textacy.preprocess_text(
# text,
# no_accents=True,
# no_punct=True,
# lowercase=True,
# fix_unicode=True,
# no_emails=True,
# no_phone_numbers=True,
# no_contractions=True
# )
# preprocessedText = textacy.preprocess.normalize_whitespace(preprocessedText)
# TODO: add lemmatizing for words

# categorize documents
Expand All @@ -64,9 +67,9 @@ def parse(self, response):
},
'title': data.css('title::text').get(),
'abstract': data.css('strong::text').get(),
'text': preprocessedText,
'text': text,
'level': categorize.categorizeText(text)
}
}
else:
continue
for a in response.css('a::attr(href)'):
Expand Down