clowwindy的杂草牧场

   :: 首页 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理
  34 Posts :: 2 Stories :: 74 Comments :: 0 Trackbacks

公告

这是上次urllib2版的升级版,直接放在Google AppEngine上跑,顺便加了星成就。不得不吐嘈某人让题目跟答案一起POST,于是不用每次解析出题目组织答案了。

#!/usr/bin/env python

from google.appengine.ext import webapp
from google.appengine.ext.webapp import util
from google.appengine.api.urlfetch import fetch
import re

class CronHandler(webapp.RequestHandler):
def get(self):
cookie
="你的cookie"
url
= 'http://bbs.2dgal.com/'

result = fetch(url + 'index.php', '', 'GET', headers = {'Cookie': cookie})
ids=re.search("id=(\d+).myid=(\d+)",result.content)
if ids:
ids=ids.groups()
result = fetch(url + 'diy_ad_move.php?id='+ids[0]+'&myid='+ids[1], 'id=2', 'GET', headers = {'Cookie': cookie})
fetch(url + 'kf_fw_ig_one.php', 'one=1&submit=%B3%E9%BD%B1%3C2%3E', 'POST', headers={'Cookie':cookie})
fetch(url
+ 'kf_star_1.php', 's1_0=%A4%C6&s1_0_ans=te&s1_1=%A4%CB&s1_1_ans=ni&s1_2=%A4%D5&s1_2_ans=fu&s1_3=%A4%D8&s1_3_ans=he&s1_4=%A4%E0&s1_4_ans=mu&ok=99&submit=%BF%AA%CA%BC%B2%E2%CA%D4', 'POST', headers={'Cookie':cookie})

def main():
application
= webapp.WSGIApplication([('/cron', CronHandler),],
debug
=True)
util.run_wsgi_app(application)

if __name__ == '__main__':
main()

获取cookie的方法是,用firefox的user agent switcher等插件把你浏览器的User-Agent设为"AppEngine-Google; (+http://code.google.com/appengine; appid: 你的appid)",登陆论坛后,在地址栏里输入javascript:alert(document.cookie),按回车即可得到。

posted on 2010-09-12 14:26 clowwindy 阅读(...) 评论(...) 编辑 收藏