社区服务
高级搜索
猴岛论坛辅助工具
发帖 回复
倒序阅读 最近浏览的帖子最近浏览的版块
0个回复

楼层直达
矮子航哥

ZxID:1516009

等级: 少将
何夜无月?何处无竹柏?但少闲人,唯吾一人者耳。

举报 只看楼主 使用道具 楼主   发表于: 2009-08-02 0
1 # -*- coding:utf-8 -*-
2 import urllib2,urllib,re,time
3 # build opener with HTTPCookieProcessor
4 o = urllib2.build_opener( urllib2.HTTPCookieProcessor() )
5 urllib2.install_opener( o )
6 # assuming the site expects 'user' and 'pass' as query params
7 user=raw_input('please enter your username:')
8 passw=raw_input('your password:')
9 p = urllib.urlencode( { 'pwuser':user, 'pwpwd':passw } )
10 p+='&jumpurl=index.php&step=2&cktime=0'
11 # perform login with params
12 f = o.open( 'http://bbs.stuhome.net/login.php?',  p )
13 data = f.read()
14 f.close()
15 # second request should automatically pass back any
16 # cookies received during login... thanks to the HTTPCookieProcessor
17 #tid=raw_input('please input tid:')
18 #f = o.open( 'http://bbs.stuhome.net/newforindex/new.php' )
19 #data = f.read()
20 #r=re.findall(r'href=(\'.*?\').*?title=(\'.*?\')',data)
21 #for i in r:
22 #    if i[0].find('news_id')==-1:
23 #        print i[0],i[1]
24 reply=[u'信败类,信败类 ',
25 u'瓜娃子。。。。',
26 u'飘过。。。',
27 u'红包拿来!!!',
28 u'给我水!!!',
29 u'I am a bot!']
30 for r in reply:
31      tid='353220'
32      rr=r.encode('gb2312')
33      post=[
34      ('atc_money','0'),
35      ('atc_rvrc','0'),
36      ('atc_title','re'),
37      ('atc_usesign','1'),
38      ('atc_convert','1'),
39      ('atc_autourl','1'),
40      ('atc_content',rr),
41      ('step','2'),
42      ('action','reply'),
43      ('fid','25'),
44      ('tid',tid),
45      ('editor','0'),
46      ('atc_attachment','none'),
47      ('verify','47368d3f')]
48      p=urllib.urlencode(post)
49      f = o.open( 'http://bbs.stuhome.net/post.php?',  p )
50      data = f.read()
51      f.close()
52    print data
53      time.sleep(5)
这就是那个什么机器人的原理
« 返回列表
发帖 回复