Last active
December 9, 2016 02:06
-
-
Save Yazaten/10d556208e8e05447ea4efbed9f87799 to your computer and use it in GitHub Desktop.
This file contains 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
# -*- coding: utf-8 -*- | |
import urllib2 | |
import time | |
import re | |
ME='yazaten' | |
judgeURL = "http://skht777.webcrow.jp/atcoder-api/submissions/list.php?id="+ME | |
codeURL = "http://skht777.webcrow.jp/atcoder-api/submissions/answer.php?id=" | |
ABC_LAST = 47 #最後に開催されたABCの番号 | |
ARC_LAST = 63 #最後に開催されたARCの番号 | |
def makeSourceFile( submID, prob_stat, number ): | |
html = urllib2.urlopen( codeURL + submID + '&contest=' + prob_stat ) | |
time.sleep(1) | |
# | |
f = open(prob_stat+'-'+number+'_'+submID+".cpp", 'w') | |
for line in html: | |
f.write(line) | |
f.close() | |
number='' | |
for i in range(1,ABC_LAST+1): | |
prob_stat = "abc" + "%03d" % i | |
html = urllib2.urlopen( judgeURL + "&contest=" + prob_stat + "&ac=true" ) #ACコードのみ取得 | |
# html = urllib2.urlopen( judgeURL + "&contest=" + prob_stat ) #全コード取得 | |
for line in html: | |
number_pos = line.find('\"number\": ') | |
if number_pos != -1 : number = line[number_pos+11:-3] | |
# | |
url_pos = line.find("\"url\": ") | |
# | |
if url_pos != -1 and line.find("submissions") != -1: | |
url = line[url_pos+8:-2] | |
submID = re.search(r'\/(\d)+',url).group(0)[1:] | |
makeSourceFile( submID, prob_stat, number ) | |
number='' | |
for i in range(1,ARC_LAST+1): | |
prob_stat = "arc" + "%03d" % i | |
html = urllib2.urlopen( judgeURL + "&contest=" + prob_stat + "&ac=true" ) | |
for line in html: | |
number_pos = line.find('\"number\": ') | |
if number_pos != -1 : number = line[number_pos+11:-3] | |
# | |
url_pos = line.find("\"url\": ") | |
# | |
if url_pos != -1 and line.find("submissions") != -1: | |
url = line[url_pos+8:-2] | |
submID = re.search(r'\/(\d)+',url).group(0)[1:] | |
makeSourceFile( submID, prob_stat, number ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment