#-*- coding:utf-8 -*-
__author__ = 'Sophie2805'
import urllib
import urllib2
import time
import re
import cookielib
jar = cookielib.CookieJar()
handler = urllib2.HTTPCookieProcessor(jar)
opener = urllib2.build_opener(handler)
params ={
'user.account':'***',
'user.pwd':'***'
}
headers = {'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0'}
url = '
http://bbs.wacai.com/'#/forum-16056-1.htmlreq = urllib2.Request(url, headers=headers)
bbs_page = urllib2.urlopen(req,urllib.urlencode(params))
bbs_html= bbs_page.read()
cookie =
bbs_page.info()['set-cookie']
print cookie
pattern_2 = 'name="formhash" value="' + '.+"'
p_2 = re.compile(pattern_2)
result_2 = p_2.findall(bbs_html)
'''
title = '签到有礼'+(time.strftime("%m.%d")+'0').strip('0')+'每天签到得铜钱,每人限回一次'
pattern_1 = '<.+>'+title
p_1 = re.compile(pattern_1)
pattern_2 = 'name="formhash" value="' + '.+"'
p_2 = re.compile(pattern_2)
result_1 = p_1.findall(bbs_html)
result_2 = p_2.findall(bbs_html)
'''
formhash = result_2[0][result_2[0].find('value="')+7:result_2[0].find('value="')+15]
link_today = '
http://bbs.wacai.com/forum.php?mod=post&action=reply&fid=16056&tid=644887&extra=&replysubmit=yes&infloat=yes&handlekey=fastpost&inajax=1'#'http://bbs.wacai.com/'+ result[0][result[0].find('a href="')+8:result[0].find(' onclick=')-1]
reply={
'formhash':formhash,
'message':'貌似是赠送到余额里面的'
}
h ={
'User-Agent' : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10.10; rv:38.0) Gecko/20100101 Firefox/38.0',
'Referer':'
http://bbs.wacai.com/thread-645253-1-1.html',
'Host':'
bbs.wacai.com',
'Cookie': cookie
}
req_thread = urllib2.Request(link_today,headers=h)
page = urllib2.urlopen(req_thread,urllib.urlencode(reply))
print '~~~~~~'
print
page.info()['set-cookie']
print '~~~~~'
print page.read()
这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。
https://www.v2ex.com/t/201435
V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。
V2EX is a community of developers, designers and creative people.