Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from bs4 import BeautifulSoup
- import requests
- url = 'https://ufc.usada.org/testing/results/sanctions/'
- res = requests.get(url).content
- soup = BeautifulSoup(res, 'html.parser')
- count = 0
- usada_counts = {}
- for row in soup.find_all('tr'):
- lastCol = row.findChild("td", class_="column-4")
- if lastCol:
- announced = lastCol.findChild("a")
- if announced:
- count += 1
- year = int(announced.contents[0].split('/')[-1].strip(';'))
- if usada_counts.get(year):
- usada_counts[year] += 1
- else:
- usada_counts[year] = 1
- print("Total USADA suspensions (excludes \"No Fault\" overturns): ", count)
- for key, val in usada_counts.items():
- print("Year: ", key, "No. of Suspensions: ", val)
Advertisement
Add Comment
Please, Sign In to add comment