summaryrefslogtreecommitdiff
path: root/unbiasedFunctions.py
diff options
context:
space:
mode:
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]=='/':