From e5068046669db39b0700b894f4191296c80f288b Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 3 Nov 2020 03:45:56 +0000 Subject: [PATCH 1/2] Clean code up --- webclient/src/Feed.js | 6 +++--- webclient/src/Results.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/webclient/src/Feed.js b/webclient/src/Feed.js index 1ae9e73..ebef3f7 100644 --- a/webclient/src/Feed.js +++ b/webclient/src/Feed.js @@ -57,15 +57,15 @@ class Feed extends React.Component { {error &&

Connection error?

} {stories ?
- {stories.map((x, i) => -
+ {stories.map(x => +
source logo {x.title} - ​({sourceLink(x)}) + ({sourceLink(x)})
diff --git a/webclient/src/Results.js b/webclient/src/Results.js index 10a4a45..1051a11 100644 --- a/webclient/src/Results.js +++ b/webclient/src/Results.js @@ -64,15 +64,15 @@ class Results extends React.Component {

Search results:

{stories.length ? - stories.map((x, i) => -
+ stories.map(x => +
source logo {x.title} - ​({sourceLink(x)}) + ({sourceLink(x)})
From 9a279d44b1d2b454970a2f3747391189b95e3563 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Tue, 3 Nov 2020 20:27:43 +0000 Subject: [PATCH 2/2] Add header to get content type --- apiserver/feed.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/apiserver/feed.py b/apiserver/feed.py index c746f0c..cbf36ed 100644 --- a/apiserver/feed.py +++ b/apiserver/feed.py @@ -64,8 +64,11 @@ def get_article(url): def get_content_type(url): try: - headers = {'User-Agent': 'Twitterbot/1.0'} - return requests.get(url, headers=headers, timeout=2).headers['content-type'] + headers = { + 'User-Agent': 'Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)', + 'X-Forwarded-For': '66.249.66.1', + } + return requests.get(url, headers=headers, timeout=5).headers['content-type'] except: pass