Skip to content

Instantly share code, notes, and snippets.

@Baekjoon
Last active August 29, 2015 14:19
Show Gist options
  • Save Baekjoon/b44e8f63babe5f44d297 to your computer and use it in GitHub Desktop.
Save Baekjoon/b44e8f63babe5f44d297 to your computer and use it in GitHub Desktop.
acmicpc-ranklist-rank-print-all
import urllib
from bs4 import BeautifulSoup
fp = urllib.urlopen('https://www.acmicpc.net/ranklist')
source = fp.read()
fp.close()
soup = BeautifulSoup(source)
table = soup.find(id="ranklist")
trs = table.tbody.find_all('tr')
for tr in trs:
tds = tr.find_all('td')
rank = int(tds[0].string.strip())
user_id = tds[1].a.span.string.strip()
quote = tds[2].string.strip()
solved = int(tds[3].a.string.strip())
submit = int(tds[4].a.string.strip())
ratio = tds[5].string.strip()
print rank,user_id,quote,solved,submit,ratio
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment