summaryrefslogtreecommitdiff
path: root/unbiasedFunctions.py
diff options
context:
space:
mode:
authorsstvinc2 <sstvinc2@gmail.com>2017-02-16 16:02:24 -0600
committersstvinc2 <sstvinc2@gmail.com>2017-02-16 16:02:24 -0600
commit53e8b692f6374b72238df797bf14e94f0567b331 (patch)
treeaa6bfb1eb1fbe35bd97028d122d30685e591729e /unbiasedFunctions.py
parent0f2b265ed3c82e674cc714785a9f308be1db9aa1 (diff)
Added The Guardian to sources
Diffstat (limited to 'unbiasedFunctions.py')
-rw-r--r--unbiasedFunctions.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/unbiasedFunctions.py b/unbiasedFunctions.py
index 57c8c6a..de27228 100644
--- a/unbiasedFunctions.py
+++ b/unbiasedFunctions.py
@@ -22,11 +22,18 @@ def buildArticle(url, sourceName):#, titleDelStart, titleDelEnd, imgDelStart, im
f.close()
try:
- #because the quote separator could be ' or ", trim to just before it then lop it off
- img=content.split('og:image" content=')[1][1:].split('>')[0]
- if img[-1]=='/':
- img=img[:-1].strip()
- img=img[:-1]
+ if sourceName=='The Guardian':
+ #The Guardian puts an identifying banner on their og:images
+ #grab the main image from the page instead
+ img=content.split('<img class="maxed', 1)[1]
+ img=img.split('src="', 1)[1].split('"')[0]
+ else:
+ img=content.split('og:image" content=')[1][1:].split('>')[0]
+ if img[-1]=='/':
+ #because the quote separator could be ' or ",
+ #trim to just before it then lop it off
+ img=img[:-1].strip()
+ img=img[:-1]
title=content.split('og:title" content=')[1][1:].split('>')[0]
if title[-1]=='/':