Skip to content

Commit 0a50379

Browse files
AJAX and Javascript
1 parent 21ed705 commit 0a50379

5 files changed

+32
-0
lines changed
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
import requests
3+
import pandas as pd
4+
5+
writer = pd.ExcelWriter(
6+
'Scrapped/AJAX and Javascript.xlsx',
7+
engine='xlsxwriter'
8+
)
9+
10+
for i in range(2010, 2016):
11+
ajax = f'https://www.scrapethissite.com/pages/ajax-javascript/?ajax=true&year={i}'
12+
r = requests.get(ajax)
13+
data = r.json()
14+
15+
for j in data:
16+
j.pop('year')
17+
18+
try: j['Best Picture'] = j.pop('best_picture')
19+
except: j['Best Picture'] = False
20+
21+
j['Title'] = j.pop('title')
22+
j['Awards'] = j.pop('awards')
23+
j['Nominations'] = j.pop('nominations')
24+
25+
df = pd.DataFrame(data)
26+
pd.DataFrame(df).to_excel(writer,
27+
sheet_name = f'Sheet_{i}',
28+
index = False,
29+
header=True
30+
)
31+
32+
writer.save()
10.2 KB
Binary file not shown.
File renamed without changes.
226 KB
Loading
File renamed without changes.

0 commit comments

Comments
 (0)