Skip to content

Commit 1bc4ecd

Browse files
committed
buildings
1 parent a19f0a2 commit 1bc4ecd

File tree

6 files changed

+47
-26
lines changed

6 files changed

+47
-26
lines changed

app.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
from resources.free_food import FreeFood
1212
from resources.ews_status import EWSStatus
1313
from resources.athletic_schedule import AthleticSchedule
14+
from resources.buildings import Buildings
1415

1516
app = Flask(__name__)
1617
api = Api(app)
@@ -33,7 +34,7 @@
3334
api.add_resource(Laundry, '/laundry')
3435
#api.add_resource(UniversityDirectory, '', '')
3536
#api.add_resource(DailyIllini, '', '')
36-
#api.add_resource(Buildings, '', '')
37+
api.add_resource(Buildings, '/buildings')
3738
api.add_resource(AthleticSchedule, '/athleticschedule/<string:sport>')
3839
#api.add(Maintenance, '', '')
3940
api.add_resource(FreeFood, '/freefood')

resources/athletic_schedule.py

+10-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
from flask_restful import Resource
22
import urllib2
33
from bs4 import BeautifulSoup
4+
import xml2json
45

56

67
BASE_URL = "http://www.fightingillini.com/schedule.aspx?path="
@@ -10,6 +11,13 @@
1011
'wcross', 'wgolf', 'wgym', 'wsoc', 'softball',
1112
'wswim', 'wten', 'wtrack', 'wvball']
1213

14+
'''class AthleticSchedule(Resource):
15+
def get(self, sport):
16+
request_url = 'http://app-uiuc-ncaa.yinzcam.com/V1/Game/List/?teamid=uiuc-' + sport + '&version=4.6&app_version=1.0.1&mcc=310&width=640&application=NCAA_UIUC&schoolid=UIUC&os=iOS&mnc=260&height=1136&os_version=9.1&ff=mobile&carrier=T-Mobile'
17+
request = urllib2.urlopen(request_url)
18+
print(type(request))
19+
return xml2json.xml2json(request.read(), None)'''
20+
1321
class AthleticSchedule(Resource):
1422
def get(self, sport):
1523
if sport.lower() in sports:
@@ -19,7 +27,7 @@ def get(self, sport):
1927
soup = BeautifulSoup(request, 'html.parser')
2028
retval = {}
2129
gamelist = []
22-
for x in soup.find_all(class_='schedule_game', ):
30+
for x in soup.find_all(class_='schedule_game'):
2331
print(x)
2432
game = {}
2533
if (x.find(class_='schedule_game_opponent_name').a is None and x.find(class_='schedule_game_opponent_name').span is None):
@@ -50,4 +58,4 @@ def get(self, sport):
5058
retval['games'] = gamelist
5159
return retval
5260
else:
53-
return {'This sport' : 'does not exist.'}
61+
return {'This sport' : 'does not exist'}

resources/buildings.py

+9
Large diffs are not rendered by default.

resources/dining.py

-23
Original file line numberDiff line numberDiff line change
@@ -17,29 +17,6 @@ def get(self, hall):
1717
class Dining(Resource):
1818
def get(self, hall, dateFrom, dateTo):
1919
request_url = "https://web.housing.illinois.edu/MobileDining2/WebService/Search.aspx?k=7A828F94-620B-4EE3-A56F-328036CC3C04"
20-
dining_halls = {
21-
"lar": 5,
22-
"fieldofgreens": 12,
23-
"leafy": 13,
24-
"par": 2,
25-
"pennstation": 14,
26-
"isr": 3,
27-
"chomps": 18,
28-
"cocinamexicana": 10,
29-
"tasteofasia": 17,
30-
"ikenberry": 1,
31-
"57north": 7,
32-
"betterburger": 20,
33-
"caffeinator": 9,
34-
"neosoulingredient": 21,
35-
"far": 6,
36-
"crackedeggcafe": 8,
37-
"soulingredient": 16,
38-
"buseyevans": 4,
39-
"buseybeanand green": 11,
40-
"oodles": 19
41-
}
42-
4320
# Add route parameters
4421
request_url += "&id=" + hall + "&from=" + dateFrom + "&to=" + dateTo + "&t=json"
4522
response = urllib2.urlopen(request_url)

todo.md

+1
Original file line numberDiff line numberDiff line change
@@ -34,3 +34,4 @@ _\( managed using [todo-md](https://github.com/Hypercubed/todo-md) \)_
3434
- [ ] https://illinois.edu/massmail/massmailArchive
3535
- [ ] Peoria charter + other bus comapanies
3636
- [ ] study spaces
37+
- [ ] redo building list with null names

tools/buildingscrape.py

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import urllib2
2+
from bs4 import BeautifulSoup
3+
4+
request = urllib2.urlopen('http://fs.illinois.edu/about-us/building-list-by-building-number')
5+
soup = BeautifulSoup(request, 'html.parser')
6+
retval = []
7+
for x in soup.find_all('tr'):
8+
ret = {}
9+
10+
ret['number'] = x.contents[1].string
11+
ret['name'] = x.contents[3].string
12+
if (x.contents[5] is None):
13+
ret['address'] = None
14+
else:
15+
ret['address'] = x.contents[5].string
16+
if (x.contents[7] is None):
17+
ret['city'] = None
18+
else:
19+
ret['city'] = x.contents[7].string
20+
if (len(x.contents) < 10 or x.contents[9] is None):
21+
ret['zipcode'] = None
22+
else:
23+
ret['zipcode'] = x.contents[9].string
24+
retval.append(ret)
25+
print retval

0 commit comments

Comments
 (0)