最简单的灌水机
时间:2006-03-29 来源:wuhen33400
#! /usr/bin/python
import urllib, urllib2, cookielib
import re, time
#####################################
#
# Globals
#
#####################################
site = 'http://www.**********.com.cn/bbs'
params = {'title':'Re:', 'body':'Up Up', 'userface':'1'}
data = urllib.urlencode(params)
####################################
#
# Store the cookie
#
####################################
cj = cookielib.CookieJar()
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
########################
#
# setup connection
#
########################
conn = opener.open(site + '/index.asp')
####################################
#
# Find the passcode and prompt user
#
####################################
conn = opener.open(site + '/code.asp')
conn.read(54) # the header of bitmap file
debug = ['', '', '', '', '', '', '', '', '', '']
s = ['', '', '', '']
bg = '\xee\xee\xee'
for x in range(0, 10):
for y in range(0, 4):
for z in range(0, 10):
data = conn.read(3)
if data == bg:
s[y] += '1'
debug[x] += ' '
else:
s[y] += '0'
debug[x] += '#'
#debug[x] += '|'
for x in range (9, -1, -1):
print debug[x]
passcode = raw_input('Please input passcode as above: ')
params = {'username':'elf_cr', 'UserPassword':'spirit', 'passcode':passcode}
data = urllib.urlencode(params)
req = urllib2.Request(site + '/chkuserj.asp', data)
conn = opener.open(req);
##############################
#
# find titles
#
##############################
conn = opener.open(site + '/jj.asp?fenlei=3')
reo = re.compile(r'titleid=(\d+)');
f = conn.readlines()
for line in f:
if line.find('titleid=') != -1:
m = reo.search(line);
tid = m.group(1)
# post my replies
print 'Re: ' + tid
conn = opener.open(site + '/saveh.asp?fenlei=2&titleid=' + tid, data)
conn.close()