您的位置:首页 > 编程语言 > Python开发

python爬队员oj题数

2015-08-17 11:42 609 查看
import urllib.request
import re

class Hdu:
ojname = "http://acm.hdu.edu.cn/userstatus.php?user="
ojmatch = "<tr><td>Problems Solved</td><td align=center>"
user = ["hzh0000","syhjh"]
userchinesename = ["胡子昊","胡佳焕"]

def Count(self):
print(self.__class__.__name__)
temp = 0
for username in self.user:
html = urllib.request.urlopen(self.ojname+username).read()
html = html.decode("gb2312")

p = re.compile(self.ojmatch)
m = p.search(html)

i = m.end()
cnt = ""
while html[i] >= '0' and html[i] <= '9':
cnt += html[i]
i += 1
print(self.userchinesename[temp]," : ", cnt)
temp += 1

class Poj:
ojname = "http://poj.org/userstatus?user_id="
ojmatch = "result=0&user_id="
user = ["hzh0000"]
userchinesename = ["胡子昊"]

def Count(self):
print(self.__class__.__name__)
temp = 0
for username in self.user:
html = urllib.request.urlopen(self.ojname+username).read()
html = html.decode("gb2312")

p = re.compile(self.ojmatch+username+'>')
m = p.search(html)

i = m.end()
cnt = ""
while html[i] >= '0' and html[i] <= '9':
cnt += html[i]
i += 1
print(self.userchinesename[temp]," : ", cnt)
temp += 1

class Cug:
ojname = "http://acm.cug.edu.cn/JudgeOnline/userinfo.php?user="
ojmatch = "&jresult=4'>"
user = ["hzh0000","zjsyhjh"]
userchinesename = ["胡子昊","胡佳焕"]

def Count(self):
print(self.__class__.__name__)
temp = 0
for username in self.user:
html = urllib.request.urlopen(self.ojname+username).read()
html = html.decode()

p = re.compile(self.ojmatch)
m = p.search(html)

i = m.end()
cnt = ""
while html[i] >= '0' and html[i] <= '9':
cnt += html[i]
i += 1
print(self.userchinesename[temp]," : ", cnt)
temp += 1

class Zoj:
ojname = "http://acm.zju.edu.cn/onlinejudge/showUserStatus.do?userId="
ojmatch = "<font size=\"3\">AC Ratio:</font> <font color=\"red\" size=\"4\">"
user = ["108596"]
userchinesename = ["胡子昊"]

def Count(self):
print(self.__class__.__name__)
temp = 0
for username in self.user:
html = urllib.request.urlopen(self.ojname+username).read()
html = html.decode()

p = re.compile(self.ojmatch)
m = p.search(html)

i = m.end()
cnt = ""
while html[i] >= '0' and html[i] <= '9':
cnt += html[i]
i += 1
print(self.userchinesename[temp]," : ", cnt)
temp += 1

alloj = [Hdu]

hdu = Hdu()
hdu.Count()

poj = Poj()
poj.Count()

cug = Cug()
cug.Count()

zoj = Zoj()
zoj.Count()
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: