Source code for AustrianNationalTeamScraper
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import requests
from bs4 import BeautifulSoup
# finds the names and the team LVL of the austrian judo national team online and stores them in a txt file
[docs]class AustrianNationalTeamScraper:
def __int__(self):
"""
creates an JBScraper Object
"""
pass
[docs] def scrapeTeam(self):
url = "https://www.oejv.com/verband/kader/"
placeToStoreResults = '../results/'
# Preparing Files
fileNameKader = placeToStoreResults + 'Kader.txt' # Name of text file coerced with +.txt
fileKader = open(fileNameKader, 'w') # ATTENTION: overwrites file
fileKader.writelines('# Kader; Name\n')
r = requests.get(url)
soupNationalTeamList = BeautifulSoup(r.content, 'html.parser')
teams = soupNationalTeamList.find_all(style="list-style-type:none;")
fighterS = ''
for teamWithImage in teams:
team = teamWithImage.find_all(style="position:relative;margin-left:180px;")
for fighter in team:
fighterDetails = fighter.find_all('b')
fighterS += fighterDetails[0].contents[0] + '; ' + fighterDetails[1].contents[0] + '\n'
# print(fighterS)
fileKader.write(fighterS)
fighterS = ''
fileKader.close()
if __name__ == "__main__":
AustrianNationalTeamScraper1 = AustrianNationalTeamScraper();
AustrianNationalTeamScraper1.scrapeTeam()