diff options
-rw-r--r-- | html_template/template.html | 1 | ||||
-rw-r--r-- | html_template/unbiased.css | 55 | ||||
-rw-r--r-- | main.py | 12 | ||||
-rw-r--r-- | parser.py | 46 | ||||
-rw-r--r-- | unbiasedFunctions.py | 1 |
5 files changed, 94 insertions, 21 deletions
diff --git a/html_template/template.html b/html_template/template.html index 1c2e858..c0e0711 100644 --- a/html_template/template.html +++ b/html_template/template.html @@ -1,6 +1,7 @@ <!DOCTYPE html>
<html>
<head>
+ <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; user-scalable=0;" />
<meta charset="utf-8">
<link rel="stylesheet" href="unbiased.css">
<title>UnBiased</title>
diff --git a/html_template/unbiased.css b/html_template/unbiased.css index 52f1b66..126e194 100644 --- a/html_template/unbiased.css +++ b/html_template/unbiased.css @@ -19,8 +19,8 @@ a:link, a:visited, a:hover, a:active { text-align:center;
padding:.5em 0 1em;
margin-bottom:1em;
- border-bottom:3px solid #f00;
- background:#44a;
+ border-bottom:3px solid #BB133E;
+ background:#002147;
}
.title{
@@ -53,6 +53,12 @@ a:link, a:visited, a:hover, a:active { margin-right:auto;
}
+@media only screen and (max-width:900px){
+ #page-container{
+ width:100%
+ }
+}
+
#top-stories{
width:95%;
display:block;
@@ -61,7 +67,7 @@ a:link, a:visited, a:hover, a:active { margin-left:auto;
margin-right:auto;
text-align:center;
- border-bottom: 3px solid #f00;
+ border-bottom: 3px solid #BB133E;
margin-bottom: 10px;
}
@@ -78,6 +84,14 @@ a:link, a:visited, a:hover, a:active { border:2px solid #ccc;
}
+@media only screen and (max-width:500px){
+ .top-story{
+ display:block;
+ width:auto;
+ height:auto;
+ }
+}
+
.top-stories-img{
width:350px;
height:200px;
@@ -87,6 +101,13 @@ a:link, a:visited, a:hover, a:active { margin:0 auto;
}
+@media only screen and (max-width:500px){
+ .top-stories-img{
+ width:auto;
+ }
+}
+
+
.top-stories-hed{
font-weight:bold;
font-size:1.35em;
@@ -109,6 +130,13 @@ a:link, a:visited, a:hover, a:active { float:left;
}
+@media only screen and (max-width:500px){
+ #middle-stories{
+ width:100%;
+ float:none;
+ }
+}
+
.middle-story{
margin:5px 10px;
padding:10px;
@@ -118,6 +146,12 @@ a:link, a:visited, a:hover, a:active { float:left;
}
+@media only screen and (max-width:500px){
+ .middle-story{
+ width:auto;
+ }
+}
+
.middle-stories-img{
width:150px;
height:100px;
@@ -125,6 +159,7 @@ a:link, a:visited, a:hover, a:active { background-size: cover;
background-position: center center;
float:left;
+ max-width:35%;
}
.middle-stories-hed{
@@ -134,6 +169,12 @@ a:link, a:visited, a:hover, a:active { margin-left:10px;
}
+@media only screen and (max-width:500px){
+ .middle-stories-hed{
+ max-width:60%;
+ }
+}
+
#bottom-stories{
margin:0 10px;
padding:10px;
@@ -144,6 +185,14 @@ a:link, a:visited, a:hover, a:active { border:5px solid #ddd;
}
+@media only screen and (max-width:900px){
+ #bottom-stories{
+ width:auto;
+ border-width:3px;
+ float:none;
+ }
+}
+
.bottom-story{
padding:15px 0;
}
@@ -15,9 +15,17 @@ def main(): def run(): sourceList=[] + ''' - #nyt=buildNYT() - #sourceList.append(nyt) + SOURCES TO ADD NEXT: + -ABC + -REUTERS + -THE HILL + + ''' + + nyt=buildNYT() + sourceList.append(nyt) npr=buildNPR() sourceList.append(npr) @@ -100,7 +100,7 @@ def removeDuplicates(h1s, h2s, h3s): -def removeBadStories(source, badTitleArr, badDescArr, badAuthorArr, badImgArr): +def removeBadStories(source, badTitleArr, badDescArr, badAuthorArr, badImgArr, badURLArr=None): arr=[source.h1Arr, source.h2Arr, source.h3Arr] @@ -159,6 +159,19 @@ def removeBadStories(source, badTitleArr, badDescArr, badAuthorArr, badImgArr): arr[1].remove(arr[1][0]) print('Removed:\n'+source.name+'\n'+hed.title+' from '+source.name+'\nReason: Image ('+item+')\n') + if badURLArr!=None: + for i in range(len(arr)): + for hed in arr[i]: + for item in badURLArr: + if item in hed.url: + arr[i].remove(hed) + #if it's in the h1 slot, bump up the + # first h2 into the h1 slot + if i==0: + arr[0].append(arr[1][0]) + arr[1].remove(arr[1][0]) + print('Removed:\n'+source.name+'\n'+hed.title+' from '+source.name+'\nReason: URL ('+item+')\n') + return source @@ -508,7 +521,7 @@ def buildWeeklyStandard(): badTitleArr=None ## if flagged again, remove Micah Mattix badDescArr=['Matt Labash'] - badAuthorArr=['MATT LABASH', 'TWS PODCAST', 'ERIC FELTEN', 'Steven J. Lenzner'] + badAuthorArr=['MATT LABASH', 'TWS PODCAST', 'ERIC FELTEN', 'Steven J. Lenzner', 'MARK HEMINGWAY'] badImgArr=['http://www.weeklystandard.com/s3/tws15/images/twitter/tws-twitter_1024x512.png'] wkl=removeBadStories(wkl, badTitleArr, badDescArr, badAuthorArr, badImgArr) @@ -518,7 +531,7 @@ def buildWeeklyStandard(): def buildNPR(): - url='http://npr.com' + url='http://www.npr.org/sections/news/' name='NPR' #DOWNLOAD HOMEPAGE CONTENT @@ -526,7 +539,7 @@ def buildNPR(): #get main headline h1=content - h1=h1.split('<div id="contentWrap">', 1)[1] + h1=h1.split('<a id="mainContent">', 1)[1] h1=h1.split('<a href="', 1)[1] h1=h1.split('"', 1)[0] h1s=[h1] @@ -534,10 +547,11 @@ def buildNPR(): #GET SECONDARY HEADLINES h2=content h2s=[] - h2=h2.split('<article class="hp-item attachment volume-low">', 1)[1] - h2=h2.split('</section>', 1)[0] - while 'href="' in h2: - h2=h2.split('href="', 1)[1] + h2=h2.split('<article class="item has-image">', 1)[1] + h2=h2.split('<!-- END CLASS=\'FEATURED-3-UP\' -->', 1)[0] + while '<article class="item has-image">' in h2: + h2=h2.split('<article class="item has-image">', 1)[1] + h2=h2.split('<a href="', 1)[1] x=h2.split('"', 1)[0] if h1 not in x: h2s.append(x) @@ -545,15 +559,16 @@ def buildNPR(): #GET TERTIARY HEADLINES h3=content h3s=[] - h3=h3.split('<ul id="nib-list">', 1)[1] - h3=h3.split('</ul>', 1)[0] - while 'href=\'' in h3: - h3=h3.split('href=\'', 1)[1] - x=h3.split('\'', 1)[0] + h3=h3.split('<div id="overflow" class="list-overflow"', 1)[1] + h3=h3.split('<!-- END ID="OVERFLOW" CLASS="LIST-OVERFLOW"', 1)[0] + while '<h2 class="title"><a href="' in h3: + h3=h3.split('<h2 class="title"><a href="', 1)[1] + x=h3.split('"', 1)[0] if h1 not in x: h3s.append(x) h1s, h2s, h3s = removeDuplicates(h1s, h2s, h3s) + npr=buildNewsSource2(name, url, h1s, h2s, h3s) #REMOVE BAD STORIES @@ -611,7 +626,8 @@ def buildFoxNews(): badDescArr=None badAuthorArr=['Bill O\'Reilly', 'Sean Hannity'] badImgArr=['http://www.foxnews.com/content/dam/fox-news/logo/og-fn-foxnews.jpg'] - fox=removeBadStories(fox, badTitleArr, badDescArr, badAuthorArr, badImgArr) + badURLArr=['http://www.foxnews.com/opinion'] + fox=removeBadStories(fox, badTitleArr, badDescArr, badAuthorArr, badImgArr, badURLArr) return fox @@ -673,8 +689,6 @@ def buildNYT(): if (h1 not in x) and (x not in h2s): h2s.append(x) - print(h2s) - #GET TERTIARY HEADLINES h3=content h3s=[] diff --git a/unbiasedFunctions.py b/unbiasedFunctions.py index 748aed7..ef0265f 100644 --- a/unbiasedFunctions.py +++ b/unbiasedFunctions.py @@ -103,6 +103,7 @@ def buildOutput(newsSourceArr): h3RandomPairs=[]
while len(h3RandomPairs) < 12:
x=random.sample(range(len(newsSourceArr)), 1)[0]
+ print(newsSourceArr[x].name)
y=random.sample(range(len(newsSourceArr[x].h3Arr)), 1)[0]
pair=[x,y]
if not pair in h3RandomPairs:
|