Guest User

Untitled

a guest
Sep 1st, 2022
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. from bs4 import BeautifulSoup
  2. import requests
  3.  
  4. url = 'https://ufc.usada.org/testing/results/sanctions/'
  5.  
  6. res = requests.get(url).content
  7. soup = BeautifulSoup(res, 'html.parser')
  8. count = 0
  9. usada_counts = {}
  10. for row in soup.find_all('tr'):
  11. lastCol = row.findChild("td", class_="column-4")
  12. if lastCol:
  13. announced = lastCol.findChild("a")
  14. if announced:
  15. count += 1
  16. year = int(announced.contents[0].split('/')[-1].strip(';'))
  17. if usada_counts.get(year):
  18. usada_counts[year] += 1
  19. else:
  20. usada_counts[year] = 1
  21.  
  22. print("Total USADA suspensions (excludes \"No Fault\" overturns): ", count)
  23. for key, val in usada_counts.items():
  24. print("Year: ", key, "No. of Suspensions: ", val)
  25.  
Advertisement
Add Comment
Please, Sign In to add comment