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()
相关文章推荐
- Python开发入门与实战17-新浪云部署
- python的socket编程
- vijos - P1319数列 (二进制 + 找规律 + python)
- Python Web Scraper - Simple Url Request
- python 编码规范
- python中xrange和range的比较
- 转载:唐磊的个人博客《python中decorator详解》【转注:深入浅出清晰明了】
- windows下 python 2.7x 安装pip
- PAT 02-3. 求前缀表达式的值(25) Python
- 使用PyQt来编写第一个Python GUI程序
- Python GUI开发环境的搭建
- Python subprocess模块学习总结
- (转载)NumPy详细教程
- 在rhel6上安装Python 2.7和Python 3.3
- 每日python(2)
- mac环境python Flask 环境搭建
- python-set
- python decimal range() step value
- python学习笔记--迭代器
- Scikit Learn: 在python中机器学习