diff options
author | ssstvinc2 <sstvinc2@gmail.com> | 2017-02-11 19:14:43 -0500 |
---|---|---|
committer | ssstvinc2 <sstvinc2@gmail.com> | 2017-02-11 19:14:43 -0500 |
commit | c233a25ea868496557d1ea211addbf87d388b4ce (patch) | |
tree | 84e561a396c13b434ef216efa0e6e42d795db25b | |
parent | 195ff07f697ffd486619f55320e5f3e8813a8eba (diff) |
Added BBC as source; added stubURL functionality
-rwxr-xr-x | main.py | 10 | ||||
-rw-r--r-- | unbiasedFunctions.py | 10 | ||||
-rw-r--r-- | unbiasedObjects.py | 8 |
3 files changed, 24 insertions, 4 deletions
@@ -15,7 +15,17 @@ def run(): sourceList=[] + sourceList.append(NewsSource('BBC US', + 'http://www.bbc.com/news/world/us_and_canada', + ['buzzard-item', '<a href="'], + ['top_stories#', '<a href="'], + [], + None, None, + '<div class="pigeon">','<div id=', + None, None, + 'http://www.bbc.com')) + sourceList.append(NewsSource('NBC News', 'http://nbcnews.com', ['top-stories-section', 'panel_hero', '<a href="'], diff --git a/unbiasedFunctions.py b/unbiasedFunctions.py index b770b60..2cdae81 100644 --- a/unbiasedFunctions.py +++ b/unbiasedFunctions.py @@ -88,7 +88,10 @@ def extractURLs(content, source): h1=h1.split(delim)[1]
h1=h1.split(source.h1DelEnd)[0]
if '.com' not in h1:
- h1=source.url+h1
+ if source.stubURL!=None:
+ h1=source.stubURL+h1
+ else:
+ h1=source.url+h1
h1s.append(h1)
h2=content
@@ -105,7 +108,10 @@ def extractURLs(content, source): x=x.split(source.h2DelEnd)[0]
h2=h2.split(source.h2DelEnd, 1)[1]
if '.com' not in x:
- x=source.url+x
+ if source.stubURL!=None:
+ x=source.stubURL+x
+ else:
+ x=source.url+x
h2s.append(x)
diff --git a/unbiasedObjects.py b/unbiasedObjects.py index 56530c5..b1f6ec5 100644 --- a/unbiasedObjects.py +++ b/unbiasedObjects.py @@ -36,12 +36,15 @@ class NewsSource(): h1Arr=None
h2Arr=None
h3Arr=None
-
+ #url to attach to stub links
+ stubURL=''
+
def __init__(self, name, url,
h1DelStart, h2DelStart, h3DelStart,
h1SectionDividerStart=None, h1SectionDividerEnd=None,
h2SectionDividerStart=None, h2SectionDividerEnd=None,
- h3SectionDividerStart=None, h3SectionDividerEnd=None):
+ h3SectionDividerStart=None, h3SectionDividerEnd=None,
+ stubURL=None):
self.name=name
self.url=url
self.h1DelStart=h1DelStart
@@ -56,6 +59,7 @@ class NewsSource(): self.h1Arr=[]
self.h2Arr=[]
self.h3Arr=[]
+ self.stubURL=stubURL
def addArticle(self, article, level):
if level==1:
|