-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
48 lines (44 loc) · 1.45 KB
/
main.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
import csv
from src.models import FestivalScrapingRequest, FestivalMovieData
from src.scraper import IMDBScraper
if __name__ == '__main__':
scraper = IMDBScraper()
requests = [
FestivalScrapingRequest(
'Berlin International Film Festival',
'https://www.imdb.com/event/ev0000091',
['2015'],
{
'Golden Berlin Bear': ['Best Film', None]
}
),
FestivalScrapingRequest(
'Cannes Film Festival',
'https://www.imdb.com/event/ev0000147',
['2000'],
{
'Palme d\'Or': [None]
}
),
FestivalScrapingRequest(
'Tokyo Film Awards',
'https://www.imdb.com/event/ev0044225',
# all movies
[],
{
'Best Short Film': [None]
}
),
]
for request in requests:
result = scraper.scrape(request)
if request.years:
filename = f'data/movies-{request.name}-{",".join(request.years)}.csv'
else:
filename = f'data/movies-{request.name}.csv'
with open(filename, 'w', newline='') as csvfile:
writer = csv.writer(csvfile, delimiter=',',
quotechar='"', quoting=csv.QUOTE_MINIMAL)
FestivalMovieData.write_header_row(writer)
for movie_data in result:
movie_data.write_row(writer)