forked from TallChris91/PASS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathText_collection_module.py
More file actions
21 lines (17 loc) · 1.09 KB
/
Text_collection_module.py
File metadata and controls
21 lines (17 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
from bs4 import BeautifulSoup
def TextCollection(templatelist, soup, homeaway, generallen, gamecourselen, gamestatisticslen):
if homeaway == 'neutral':
team2 = 'Verslag voor de neutrale toeschouwer'
else:
team = soup.find('highlights').find(homeaway).find('team').text
team2 = 'Verslag voor de achterban van ' + team
general = templatelist[:generallen]
gamecourse = templatelist[generallen:generallen+gamecourselen]
gamestatistics = templatelist[generallen+gamecourselen:generallen+gamecourselen+gamestatisticslen]
if generallen != generallen + gamecourselen:
allstring = team2 + '\n' + general[0] + '\n' + ' '.join(general[1:]) + '\n' + ' '.join(gamecourse) + '\n' + ' '.join(gamestatistics)
else:
allstring = team2 + '\n' + general[0] + '\n' + ' '.join(general[1:]) + '\n' + ' '.join(gamestatistics)
#Add a dictionary for the web implementation
paragraphdict = {'title': general[0], 'general': ' '.join(general[1:]), 'game_course': ' '.join(gamecourse), 'game_statistics': ' '.join(gamestatistics)}
return allstring, paragraphdict