summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorssstvinc2 <sstvinc2@gmail.com>2017-02-11 17:18:26 -0500
committerssstvinc2 <sstvinc2@gmail.com>2017-02-11 17:18:26 -0500
commit2669db6a582c492c70645da53ec26cd1f9ef2cd9 (patch)
tree0f66a3653257d2586008792f67e415eda11383bc
parentb3b5364c5bbb8a8e5c042e3e36d75b2aea4b2e7b (diff)
Added 'description' field to Article class
-rwxr-xr-xmain.py2
-rw-r--r--unbiasedFunctions.py12
-rw-r--r--unbiasedObjects.py6
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():
['<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():