-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.py
More file actions
30 lines (21 loc) · 945 Bytes
/
test.py
File metadata and controls
30 lines (21 loc) · 945 Bytes
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
import requests
import pandas as pd
import re
school = 'ironhack'
def remove_tags(x):
return TAG_RE.sub('', x)
TAG_RE = re.compile(r'<[^>]+>')
# defines url to make api call to data -> dynamic with school if you want to scrape competition
url = "https://www.switchup.org/chimera/v1/school-review-list?mainTemplate=school-review-list&path=%2Fbootcamps%2F" + \
school + "&isDataTarget=false&page=3&perPage=10000&simpleHtml=true&truncationLength=250"
# makes get request and converts answer to json
# url defines the page of all the information, request is made, and information is returned to data variable
data = requests.get(url).json()
print(data)
# converts json to dataframe
#reviews = pd.DataFrame(data['content']['reviews'])
# aux function to apply regex and remove tags
#reviews['review_body'] = reviews['body'].apply(remove_tags)
#reviews['school'] = school
# for i in range(0, 20):
# print(reviews['review_body'][i])