diff options
author | ssstvinc2 <sstvinc2@gmail.com> | 2017-02-09 20:24:25 -0500 |
---|---|---|
committer | ssstvinc2 <sstvinc2@gmail.com> | 2017-02-09 20:24:25 -0500 |
commit | cbbd1122c78834b1beef349797d142ed6d23218a (patch) | |
tree | 2afab3496e02cc1744e413d82ce509a25e3465f1 | |
parent | 439b2cf7317af9444e99ba58188d7ce80a906af5 (diff) |
Added/tweaked a few news sources, and added a source list to the page
-rwxr-xr-x | html_template/template.html | 4 | ||||
-rwxr-xr-x | html_template/unbiased.css | 6 | ||||
-rwxr-xr-x | main.py | 65 | ||||
-rw-r--r-- | unbiasedFunctions.py | 10 |
4 files changed, 63 insertions, 22 deletions
diff --git a/html_template/template.html b/html_template/template.html index 7869155..76b8681 100755 --- a/html_template/template.html +++ b/html_template/template.html @@ -109,5 +109,9 @@ </div>
</div>
+
+<div id="sources">
+ Sources: xxSourcesxx
+</div>
</body>
</html>
diff --git a/html_template/unbiased.css b/html_template/unbiased.css index 83bae40..d1b1460 100755 --- a/html_template/unbiased.css +++ b/html_template/unbiased.css @@ -85,4 +85,10 @@ .middle-story p{
display:block;
+}
+
+#sources{
+ clear:both;
+ padding-top:4em;
+ font-size:.8em;
}
\ No newline at end of file @@ -13,10 +13,55 @@ def main(): def run(): sourceList=[] + + + + sourceList.append(NewsSource('NBC News', + 'http://nbcnews.com', + ['top-stories-section', 'panel_hero', '<a href="'], + ['<div class="story-link', '<a href="'], + [], + None, None, + 'ad-content ad-xs mobilebox1', 'panel panel_default', + None, None)) + + + sourceList.append(NewsSource('CBS News', + 'http://cbsnews.com', + ['<a href="'], + ['<li data-tb-region-item>', '<a href="'], + [], + 'Big News Area Side Assets', '</a>' + 'Big News Area Side Assets', '</ul></div>', + None, None)) + + + + sourceList.append(NewsSource('The Blaze', + 'http://theblaze.com', + ['<a class="gallery-link" href="'], + ['</figure>\n\n<figure class="gallery-item">', 'href="'], + [], + '<!-- home -->', '<!-- loop-home -->', + '<!-- home -->', '<!-- loop-home -->', + None, None)) + + + sourceList.append(NewsSource('Weekly Standard', + 'http://www.weeklystandard.com/', + ['<div class="lead-photo">', 'href="'], + ['<div class="lead-photo">', 'href="'], + [], + '<div id="region_1"', '<div id="region_2"', + '<div class="widget lead-story layout-3col-feature" data-count="2">', '<div id="region_2"', + None, None)) + + + sourceList.append(NewsSource('New York Times', 'http://nytimes.com', ['<a href="'],#'<h1 class="story-heading"><a href="'],#['"b-column column', 'h2 class="story-heading"><a href="'], - ['article class="story theme-summary', 'h2 class="story-heading"><a href="'], + ['<article', '<a href="'], ['<hr class="single-rule"', 'article class="story theme-summary', 'h2 class="story-heading"><a href="'], '<div class="b-column column">', '<!-- close photo-spot-region -->', 'section id="top-news" class="top-news"', '</div><!-- close a-column -->', @@ -33,24 +78,6 @@ def run(): - sourceList.append(NewsSource('NBC News', - 'http://nbcnews.com', - ['top-stories-section', 'panel_hero', '<a href="'], - ['panel panel_default', '<a href="'], - [], - None, None, - 'row_no-clear ad-container ad-container_default ad-hide ad-container-mobilebox1', 'js-more-topstories', - None, None)) - - - sourceList.append(NewsSource('CBS News', - 'http://cbsnews.com', - ['<h1 class="title"><a href="'], - ['<li data-tb-region-item>', '<a href="'], - [], - None, None, - 'Big News Area Side Assets', '</ul></div>', - None, None)) #scrape all urls and build data structure newsSourceArr=buildNewsSourceArr(sourceList) diff --git a/unbiasedFunctions.py b/unbiasedFunctions.py index 84b4ec9..fc6f45b 100644 --- a/unbiasedFunctions.py +++ b/unbiasedFunctions.py @@ -86,8 +86,6 @@ def extractURLs(content, source): h1=source.url+h1
h1s.append(h1)
-
-
h2=content
if source.h2SectionDividerStart!=None:
h2=h2.split(source.h2SectionDividerStart, 1)[1]
@@ -198,7 +196,13 @@ def buildOutput(newsSourceArr): template=template.replace('xxTitle2-'+str(i+1)+'xx', article.title)
template=template.replace('xxImg2-'+str(i+1)+'xx', article.img)
-
+ sourcesStr=''
+ for i in range(len(newsSourceArr)-1):
+ sourcesStr+=newsSourceArr[i].name+', '
+ sourcesStr+=newsSourceArr[-1].name
+ print(sourcesStr)
+ template=template.replace('xxSourcesxx', sourcesStr)
+
#return updated text
return template
|