Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # import libraries
- import requests
- from bs4 import BeautifulSoup
- # set variables
- url = "https://codercc.svc.4prj.ru/stat/monthly/1"
- page = requests.get(url)
- year_dict = {}
- # Create a BeautifulSoup object
- soup = BeautifulSoup(page.text, 'html.parser')
- # Pull section with data
- stat_table = soup.find(class_='row')
- stat_boxes = stat_table.find_all('div', class_='box')
- for stat_box in stat_boxes:
- box_header = stat_box.find('h3')
- print(box_header.get_text())
- box_table = stat_box.find('table')
- box_rows = box_table.find_all('tr')
- for row in box_rows:
- name = row.find_all('a', role="button")
- hidden_table = row.find_all('table')
- if len(hidden_table) > 0:
- hidden_table[0].decompose()
- columns = row.find_all('td')
- if len(name) > 0:
- n = name[0]
- print(n.text)
- scores = columns[6].text
- print(scores)
- # get date from the content
- content = soup.find(class_='content')
- children = content.findChildren()
- for child in children:
- child.decompose()
- date = content.get_text()
- date = date.strip()
- date = date.split(' ')
- year_dict[date[1]] = {}
- print(year_dict)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement