python做游戏脚本被监测_一个监视CSDN论坛押宝游戏状态的python脚本
# -*- encoding:UTF-8 -*-#以指定的时间间隔获取CSDN押宝游戏的结果#网址:http://community.csdn.net/Games/GamePawn.aspx?id=395&_t_fq8zksdaimport sys, urllibimport reimport chardetdef getCharset(string):#todo : automatic
# -*- encoding:UTF-8 -*-
#以指定的时间间隔获取CSDN押宝游戏的结果
#网址:http://community.csdn.net/Games/GamePawn.aspx?id=395&_t_fq8zksda
import sys, urllib
import re
import chardet
def getCharset(string):
#todo : automatic discern the charset
charset = chardet.detect(string)
return charset['encoding']
url = "http://community.csdn.net/Games/GamePawn.aspx?id=395&_t_fq8zksda"
#网页地址
wp = urllib.urlopen(url)
#打开连接
pattern = "(/d+)[/s/t]+/"
p = re.compile(pattern, re.S | re.M);
#匹配串的字符集
print getCharset(pattern)
#获取页面内容
while 1:
content = wp.read()
if not content:
break
content = unicode(content, getCharset(content)).encode("gb2312")
m = p.findall(content)[0:]
desc = ['A: P都没有',
'B: 红包里面两张红票票打发小朋友',
'C: 多一个月薪水罢了',
'D: 1-3K',
'E: 3-5K',
'F: 5-7K',
'G: 7-10K',
'H: 10-15K',
'I: 15-20K',
'J: 20K以上的哥们,你还是赞助吧(本项不列入本次押宝评分)',
]
#打印当前的胜者
subs = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19]
max = 0;
current_max = 0;
for sub in subs:
print m[sub]
if m[sub] > max:
max = m[sub]
current_max = sub / 2;
desc = ['A: P都没有',
'B: 红包里面两张红票票打发小朋友',
'C: 多一个月薪水罢了',
'D: 1-3K',
'E: 3-5K',
'F: 5-7K',
'G: 7-10K',
'H: 10-15K',
'I: 15-20K',
'J: 20K以上的哥们,你还是赞助吧(本项不列入本次押宝评分)',
]
winner_desc = "当前胜者是:" + desc[current_max]
print unicode(winner_desc, getCharset(winner_desc))
#关闭
wp.close()
#等待输入
input()
更多推荐



所有评论(0)