diff options
-rwxr-xr-x | main.py | 2 | ||||
-rw-r--r-- | unbiasedFunctions.py | 12 | ||||
-rw-r--r-- | unbiasedObjects.py | 6 |
3 files changed, 14 insertions, 6 deletions
@@ -22,7 +22,7 @@ def run(): ['<div class="story-link', '<a href="'], [], None, None, - 'ad-content ad-xs mobilebox1', 'panel panel_default', + 'ad-content ad-xs mobilebox1', 'taboola-native-top-stories-thumbnail', None, None)) diff --git a/unbiasedFunctions.py b/unbiasedFunctions.py index fc6f45b..a2585e5 100644 --- a/unbiasedFunctions.py +++ b/unbiasedFunctions.py @@ -18,17 +18,22 @@ def buildArticle(url, sourceName):#, titleDelStart, titleDelEnd, imgDelStart, im f.close()
#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]#[:-1]
+ img=content.split('og:image" content=')[1][1:].split('>')[0]
if img[-1]=='/':
img=img[:-1].strip()
img=img[:-1]
- title=content.split('og:title" content=')[1][1:].split('>')[0]#[1].split('"')[0]
+ title=content.split('og:title" content=')[1][1:].split('>')[0]
if title[-1]=='/':
title=title[:-1].strip()
title=title[:-1]
+
+ description=content.split('og:description" content=')[1][1:].split('>')[0]
+ if description[-1]=='/':
+ description=description[:-1].strip()
+ description=description[:-1]
- a=Article(title, url, img, sourceName)
+ a=Article(title, url, img, description, sourceName)
return a
@@ -190,6 +195,7 @@ def buildOutput(newsSourceArr): for i in range(len(h2RandomSources)):
source=newsSourceArr[h2RandomSources[i]]
+ print(source.name)
randomArticle=random.sample(range(len(source.h2Arr)), 1)[0]
article=source.h2Arr[randomArticle]
template=template.replace('xxURL2-'+str(i+1)+'xx', article.url)
diff --git a/unbiasedObjects.py b/unbiasedObjects.py index dd71711..56530c5 100644 --- a/unbiasedObjects.py +++ b/unbiasedObjects.py @@ -2,16 +2,18 @@ class Article(): title=''
url=''
img=''
+ description=''
source=''
- def __init__(self, title, url, img, source):
+ def __init__(self, title, url, img, description, source):
self.title=title
self.url=url
self.img=img
+ self.description=description
self.source=source
def __str__(self):
- return '-----------\n'+self.title+'\n'+self.source+'\n'+self.url+'\n'+self.img+'\n'+'-----------'
+ return '-----------\n'+self.title+'\n'+self.source+'\n'+self.description+'\n'+self.url+'\n'+self.img+'\n'+'-----------'
class NewsSource():
|