Created
August 8, 2016 05:56
-
-
Save vinay13/2dcad9fbd32b10786bca25d8a1e1c31a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
import requests | |
import bs4 | |
from apscheduler.schedulers.blocking import BlockingScheduler | |
def CheckWin(): | |
url = 'http://www.nbcolympics.com/medals' | |
response = requests.get(url) | |
html = response.content | |
#[sudo] gem install terminal-notifier for osx | |
def notify(title, subtitle, message): | |
t = '-title {!r}'.format(title) | |
s = '-subtitle {!r}'.format(subtitle) | |
m = '-message {!r}'.format(message) | |
os.system('terminal-notifier {}'.format(' '.join([m, t, s]))) | |
country = [] | |
soup = bs4.BeautifulSoup(html,'html.parser') | |
table = soup.find('table') | |
#for row in table.findAll('tr'): | |
for cell in table.findAll('a'): | |
find_india=cell.text.strip() | |
#find_india=cell.text.replace(' ', '') | |
#find_india | |
#find_india.replace("u'\n\n'",'') | |
country.append(str(find_india)) | |
#print country | |
if 'India' in country: | |
return notify(title = 'India Win', | |
subtitle = 'in rio olympic', | |
message = 'Yeah!!, We won .. hurrayyy') | |
#print "we won!!" | |
else: | |
return notify(title = 'No Win Yet', | |
subtitle = 'in rio olympic', | |
message = 'best of luck india') | |
scheduler = BlockingScheduler() | |
scheduler.add_job(CheckWin, 'interval', hours=15) | |
scheduler.start() | |
""" | |
html = | |
<html> | |
<body> | |
<table> | |
<tr> | |
<td>45</td> | |
</tr> | |
</table> | |
</body> | |
</html> | |
""" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment