-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtextfrommilan.py
More file actions
67 lines (57 loc) · 2.19 KB
/
textfrommilan.py
File metadata and controls
67 lines (57 loc) · 2.19 KB
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
from splinter import Browser
import sys, time
from twilio.rest import Client
account_sid = "ACf4c0b57408f916faa17aef730562cb61"
auth_token = "f323736f3adaf0a8984364ec9131eb92"
client = Client(account_sid, auth_token)
def main():
if len(sys.argv) > 1:
print "Welcome to bare minimum web page checking."
url = sys.argv[1]
if len(sys.argv) < 3:
print "interval not stated please state now, default ten seconds."
interval = 10
elif len(sys.argv) == 3:
interval = sys.argv[2]
else:
interval = sys.argv[2]
check(url, interval)
else:
print "url and time was not given program defaulting to ten second interval, and cnn.com."
interval = 10
url = "http://www.cnn.com/"
check(url, interval)
def check(url, interval):
try:
browser = Browser('chrome')
browser.driver.set_window_size(1000,800)
browser.visit(url)
Original = len(browser.find_by_xpath('/html').text.encode('utf-8'))
browser.quit()
while True:
print('To exit program ctrl+c')
browser = Browser('chrome')
browser.driver.set_window_size(1000,800)
browser.visit(url)
New = len(browser.find_by_xpath('/html').text.encode('utf-8'))
if New != Original:
changeMessage=("PAGE CHANGED from %d bytes to %d bytes!" % (Original, New))
print changeMessage
Original = New
message = client.messages.create(
to="+15037043189",
from_="+19718034237",
body=changeMessage)
else:
print("No change detected")
message = client.messages.create(
to="+15037043189",
from_="+19718034237",
body="No change detected")
time.sleep(float(interval))
browser.quit()
except KeyboardInterrupt:
print('Thank you for running this program exiting now.')
sys.exit()
if __name__ == '__main__':
main()