Skip to content

Instantly share code, notes, and snippets.

@msaroufim
Created July 28, 2017 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save msaroufim/f8384d0d8e4c9580f9e55c3d1b1100e5 to your computer and use it in GitHub Desktop.
Save msaroufim/f8384d0d8e4c9580f9e55c3d1b1100e5 to your computer and use it in GitHub Desktop.
from bs4 import BeautifulSoup
import requests
import csv
leaderboard_root_url = 'http://www.dota2.com/leaderboards#'
regions = ['americas','europe', 'se_asia', 'china']
for region in regions:
page = requests.get(leaderboard_root_url + region).content
soup = BeautifulSoup(page, "html5lib")
soup.prettify()
leaderboard_table_rows = soup.find("tbody", {"id" : "leaderboard_body"}).findAll("tr")
for row_number, row in enumerate(leaderboard_table_rows):
cells = row.findAll("td")
print(td[2][2].text)
print(td[2][3].text)
print(td[3].text)
team_tag = row.find("td:nth-child(2) > span.team_tag")
player_name = row.find("td:nth-child(2) > span.team_tag")
solo_mmr = row.find("td:nth-child(3)")
# print(team_tag,player_name,solo_mmr,region)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment