-
Notifications
You must be signed in to change notification settings - Fork 0
/
uscwebreg.py
60 lines (47 loc) · 1.97 KB
/
uscwebreg.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
from urllib.request import urlopen
from bs4 import BeautifulSoup
from twilio.rest import Client #SMS API Package
import re
import time
import urllib.request as urlRequest
import urllib.parse as urlParse
#*editable line*
url = "http://classes.usc.edu/term-20183/classes/thtr"
# pretend to be a chrome 47 browser on a windows 10 machine
headers = {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36"}
req = urlRequest.Request(url, headers = headers)
x = urlRequest.urlopen(req)
allTheHTML = BeautifulSoup(x, 'html.parser')
#*editable line*
name_box = allTheHTML.find('tr', attrs={'class': '62633 even'})
name = name_box.text.strip()
name = name.encode("utf-8")
print (name)
###TWILIO STUFF
account_sid = "AC3c602a60289e0d8b78c843ab743090e1" #Your Twilio account ID
auth_token = "70a0b92d0cf1d2478dfc5e1c376ed0ec" #Your secret API Token
client = Client(account_sid, auth_token)
while 1:
newX = urlRequest.urlopen(req)
newAllTheHTML = BeautifulSoup(newX, 'html.parser')
#*editable line*
new_name_box = newAllTheHTML.find('tr', attrs={'class': '62633 even'})
newName = new_name_box.text.strip()
newName = newName.encode("utf-8")
print (newName)
if newName != name:
msg = client.messages.create(to="3528704348", from_="3524152946", body="IT'S UP! IT'S UP!!! IT IS OPENNNN") #Will send SMS to your phone number
print ("SMS Sent Thanks")
name = newName
quit()
else:
print ("Nothing here. Going to sleep for a couple hours") #will not send anything
time.sleep(300) #sleep for 2 hours
###You know how to change this:
###just change certain *LINES*
###the url
###the div and identifier key, value
###How this works:
###Have old name --> grab a new name and check against in every while loop
###If same: sleep, if different send text and set old to the current new
###Authenitfication for users on balckboard - check grades