forked from miker123/Python-Web-Scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
getBreakingNews.py
32 lines (26 loc) · 867 Bytes
/
getBreakingNews.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
#!/usr/bin/env python
#This program gets news from BreakingNews.com
#Written By Mike R
#April 13th-14th, 2015
#What this does is prints the time and any new net news from breakingnews.com
from bs4 import BeautifulSoup
import urllib
import time
localtime = time.asctime( time.localtime(time.time()) )
print "Breaking News at :", localtime
print "------------------------\n\n"
stories=[]
while True:
html=urllib.urlopen('http://www.breakingnews.com')
bt=html.read()
soup=BeautifulSoup(bt)
for link in soup.findAll('div', {'class': 'headline'}):
#print link.extract() prints everything selected
story=link.get_text()
if story not in stories:
localtime = time.asctime( time.localtime(time.time()) )
print "\n\nBreaking News at :", localtime
print "------------------------\n"
stories.append(story)
print story + "\n\n"
time.sleep(60)