-
Notifications
You must be signed in to change notification settings - Fork 0
/
glassdoorapi.py
52 lines (51 loc) · 1.99 KB
/
glassdoorapi.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
from glassdoor import get
# *****************************************************************************
def extract_fields(response):
satisfaction, ceo, meta, salary = None, None, None, None
for key, value in response.iteritems():
if key == 'satisfaction':
satisfaction = value
elif key == 'ceo':
ceo = value
elif key == 'meta':
meta = value
elif key == 'salary':
salary = value
return (satisfaction, ceo, meta, salary)
# *****************************************************************************
def extract_satisfaction(satisfaction):
numRatings, score = None, None
for key, value in satisfaction.iteritems():
if key == 'ratings':
numRatings = value
elif key == 'score':
score = value
return (numRatings, score)
# *****************************************************************************
def extract_ceo(ceo):
numCEOReviews, approvalRate, name, avatarLink = None, None, None, None
for key, value in ceo.iteritems():
if key == 'reviews':
numCEOReviews = value
elif key == '%approval':
approvalRate = value
elif key == 'name':
name = value
elif key == 'avatar':
avatarLink = value
return (numCEOReviews, approvalRate, name, avatarLink)
# *****************************************************************************
def main():
response = get('dropbox')
print response
print '-' * 100
for key, value in response.iteritems():
print "(%s: %s)" % (key, value)
print '-' * 100
(satisfaction, ceo, meta, salary) = extract_fields(response)
(numRatings, score) = extract_satisfaction(satisfaction)
(numCEOReviews, approvalRate, name, avatarLink) = extract_ceo(ceo)
print "numRatings: %d, score: %d" % (numRatings, score)
print "numCEOReviews: %d, approvalRate: %d, name: %s" % (numCEOReviews, approvalRate, name)
if __name__ == '__main__':
main()