From 2669db6a582c492c70645da53ec26cd1f9ef2cd9 Mon Sep 17 00:00:00 2001 From: ssstvinc2 Date: Sat, 11 Feb 2017 17:18:26 -0500 Subject: Added 'description' field to Article class --- main.py | 2 +- unbiasedFunctions.py | 12 +++++++++--- unbiasedObjects.py | 6 ++++-- 3 files changed, 14 insertions(+), 6 deletions(-) diff --git a/main.py b/main.py index 55c9560..ada2e37 100755 --- a/main.py +++ b/main.py @@ -22,7 +22,7 @@ def run(): ['
')[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(): -- cgit v1.2.3