Created
April 13, 2015 14:30
-
-
Save Baekjoon/1a023658771bc85597a5 to your computer and use it in GitHub Desktop.
acmicpc-ranklist-rank-user-id
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = tds[0].string | |
user_id = tds[1].a.span.string | |
print rank,user_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment