-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcricscores_desktop_notifications.py
130 lines (98 loc) · 3.16 KB
/
cricscores_desktop_notifications.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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
from selenium import webdriver
from selenium.webdriver.support import ui
from selenium.webdriver.common.keys import Keys
import requests
import gi
from threading import Thread
gi.require_version('Notify', '0.7') #to avoid unwanted warnings
from gi.repository import Notify
from playsound import playsound
import time
Notify.init("Test App") #desktop notification initialization
Notify.Notification.new(
"Cric Notify!!!",
"WELCOME",
"/home/shivank/python/cric.jpeg"
).show()
playsound('/home/shivank/python/pop.mp3')
def check():
time.sleep(2)
if answer=='exit':
return 0
elif answer == None:
return 1
print "Too Slow"
from Tkinter import *
x=0
def value(val,root):
global x
x=val
root.destroy()
def gui_show(s1,s2,s3,s4):
root=Tk()
button1=Button(root,text=s1,bg='light blue',fg='red',command= lambda: value(1,root))
button2=Button(root,text=s2,bg='light blue',fg='red',command= lambda: value(2,root))
button3=Button(root,text=s3,bg='light blue',fg='red',command= lambda: value(3,root))
button4=Button(root,text=s4,bg='light blue',fg='red',command= lambda: value(4,root))
button1.pack(fill=X)
button2.pack(fill=X)
button3.pack(fill=X)
button4.pack(fill=X)
root.mainloop()
# chromeOptions = webdriver.ChromeOptions()
# prefs = {"profile.managed_default_content_settings.images":2}
# chromeOptions.add_experimental_option("prefs",prefs)
#to prevent images from loading
# driver = webdriver.Chrome(executable_path="/usr/lib/chromium-browser/chromedriver",chrome_options=chromeOptions)
#opening Chrome
driver=webdriver.PhantomJS(service_args=['--load-images=no'])
driver.get("http://www.cricbuzz.com/") #specifying the website
matches=driver.find_elements_by_class_name("cb-font-12")
count =0
a = ["" for x in range(4)]
for element in matches:
if (count<=3):
#print str(count+1) + "." + element.text #display the matches going on
a[count]=element.text
count=count+1
gui_show(a[0],a[1],a[2],a[3])
# x=int(input())
#print "x:",x
#driver.save_screenshot('testing.png') #selecting the match we want to display the score for
matches[x-1].click()
exit=0
while(1):
score=driver.find_element_by_xpath('//*[@id="matchCenter"]/div[3]/div[2]/div[1]/div[1]/div[1]/div[1]/h2')
#score=driver.find_element_by_xpath('//*[@id="matchCenter"]/div[3]/div[2]/div[2]')
curr=driver.find_element_by_xpath('//*[@id="matchCenter"]/div[3]/div[2]/div[1]/div[2]')
#message = score.text+curr.text
# print "score",score.text
# print "curr",curr.text.replace('\n',' ')
curr=curr.text.replace('\n',' ')
message=curr[:18]+'\n'+curr[18:]
Notify.Notification.new(
"Cric Notify!!!",
score.text,
"/home/shivank/python/cric.jpeg"
).show()
Notify.Notification.new(
"Cric Notify!!!",
message,
"/home/shivank/python/cric.jpeg"
).show()
playsound('/home/shivank/python/pop.mp3')
# answer = None
# Thread(target = check).start()
# answer = raw_input("Input something: ")
# if answer==0:
# break
# print "success"
# try:
# answer = input_with_timeout(prompt, 10)
# except TimeoutExpired:
# print('Sorry, times up')
# else:
# print('Got %r' % answer)
time.sleep(50)
driver.refresh()
driver.quit()