Skip to content

Instantly share code, notes, and snippets.

@wasi0013
Created June 29, 2015 15:52
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 wasi0013/bfcfe0201438f48acf3e to your computer and use it in GitHub Desktop.
Save wasi0013/bfcfe0201438f48acf3e to your computer and use it in GitHub Desktop.
parses spoj's Bangladesh ranklist (http://www.spoj.com/ranks/users/BD/) to get 100 top users of Spoj from country Bangladesh
__author__ = "wasi0013"
"""
parses spoj's Bangladesh ranklist (http://www.spoj.com/ranks/users/BD/) to get
100 top users of Spoj from country Bangladesh
"""
import requests, bs4
url = 'http://spoj.com/ranks/users/BD'
def get_user():
response = requests.get(url)
soup = bs4.BeautifulSoup(response.text)
table = soup.select('div.row table')
rows = [row.select('tr') for row in table][0]
for td in rows:
print ""
for items in zip(['ranking', "name", "classical(problems)", "challenge", "points"], [row.getText() for row in td.select('td')]):
print(items[0]+": "+items[1])
get_user()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment