-
Notifications
You must be signed in to change notification settings - Fork 5
/
MaWPUP_webscraper.py
73 lines (60 loc) · 1.52 KB
/
MaWPUP_webscraper.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
import urllib2
import time
from twilio.rest import Client
account_sid = 'XXX'
auth_token = 'XXX'
twilio_phone_number = '+XXX'
my_phone_number = '+XXX'
def WebData():
link = raw_input("Paste URL here:")
sec = int(raw_input("How many seconds do you want to test for? If you would like to run until a change is detected enter 0."))
URL = urllib2.urlopen(link)
data = URL.read()
datastring = str(data)
lengthB = len(datastring)
timeT = 0
if sec == 0:
while True:
URL = urllib2.urlopen(link)
data = URL.read()
datastring = str(data)
lengthA = len(datastring)
print "Testing..."
if lengthB != lengthA:
print "The site has changed!"
body = "The price has changed!"
client = Client(account_sid, auth_token)
client.messages.create(
body=body,
to=my_phone_number,
from_=twilio_phone_number
)
break
else:
lengthA = lengthB
timeT += 1
time.sleep(1)
else:
while timeT < sec:
URL = urllib2.urlopen(link)
data = URL.read()
datastring = str(data)
lengthA = len(datastring)
print "Testing..."
if lengthB != lengthA:
print "The site has changed!"
body = "The price has changed!"
client = Client(account_sid, auth_token)
client.messages.create(
body=body,
to=my_phone_number,
from_=twilio_phone_number
)
break
else:
lengthA = lengthB
timeT += 1
time.sleep(1)
if timeT == sec:
print "No changes were made."
WebData()