-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
53 lines (47 loc) · 2.13 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
49
50
51
52
53
import time
import random
import ff_eurofunctions as eurof
#Introduction
print("Ta ta-tarara ta taaa taa (imagine the music of Charpentier's 'Te Deum' right now)...\n")
time.sleep(3)
print("Welcome to mucbib Eurovision-Data, a web scraper which lets you download and save data from the Eurovision Song Contest.\n")
print("This program is licensed under MIT. See https://github.com/mucbib/Eurovision-Data for more information.\n")
time.sleep(5)
cities = ['Turin', 'Tel Aviv', 'Rotterdam', 'Lisbon', 'Kyiv', 'Stockholm', 'Vienna', 'Dublin', 'Copenhagen', 'Belgrade', 'Baku', 'Liverpool']
randomcity = random.choice(cities)
print(f"Okay, {randomcity}, are you ready ?\n")
time.sleep(2)
#User interaction: definition of what to scrape
print("Do you want to download all data from all contests from 1956 until today, including semi-finals ? (enter 'yes')")
print("Or do you want to set your own preferences (years and shows) ? (in that case enter 'no' or your favourite song by Carola).")
answer = input("yes/no: ").strip().lower()
#if yes: scrape everything
if answer == 'yes' or answer == 'y':
eurof.scrapingwikifinal(True)
time.sleep(1)
eurof.scrapingwikisemi(True)
time.sleep(1)
eurof.merging()
else:
#if no: customized scraping
print("Set your preferences. Step 1:")
print("Do you want to get data for contests between 1956 and 2003 and/or the finals after 2004 ? (enter 'yes')")
both = 0
answerfinal = input("yes/no: ").strip().lower()
if answerfinal == 'yes' or answerfinal == 'y':
eurof.scrapingwikifinal(False)
both = both + 1
time.sleep(1)
print("Step 2: Do you want to get data for semi-finals ? (enter 'yes')")
answersemi = input("yes/no: ").strip().lower()
if answersemi == 'yes' or answersemi == 'y':
eurof.scrapingwikisemi(False)
both = both + 1
time.sleep(1)
#if the user has chosen to scrape both data from semi-finals and finals, ask if the two tables should be merged
if both == 2:
print("Do you want to merge the results from semi-finals and finals in one table ?")
answermerge = input("yes/no: ").strip().lower()
if answermerge == 'yes' or answermerge == 'y':
eurof.merging()
print("End of program. Good night Europe !")