Skip to content

Instantly share code, notes, and snippets.

@paulw54jrn
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save paulw54jrn/b98dda3e8be2c95661d9 to your computer and use it in GitHub Desktop.
Save paulw54jrn/b98dda3e8be2c95661d9 to your computer and use it in GitHub Desktop.
def get_content_length(dic):
length = 0
for key,value in dic.iteritems():
length += len(key) + len(value)
return length
def bump(session):
r = session.get('http://someurl')
formhash = re.findall(r'<input type="hidden" name="formhash" value="(.*)" />',r.text)[0]
param = {
'mod':'post',
'action':'reply',
'fid':'626',
'tid':'12345678',
'extra':'',
'replysubmit':'yes',
'infloat':'yes',
'handlekey':'fastpost',
'inajax':'1'
}
data = {
'message':'bumpbumpbumpbump',
'formhash':formhash,
'subject':''
}
headers = {
'Accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
'Accept-Encoding':'gzip,deflate',
'Accept-Language':'en-US,en;q=0.8',
'Cache-Control':'no-cache',
'Connection':'keep-alive',
'Content-Type':'application/x-www-form-urlencoded',
'Content-Length': get_content_length(data),
'DNT':'1',
'Host':'www.yeeyi.com',
'Origin':'http://www.yeeyi.com',
'Pragma':'no-cache',
'Referer':'http://www.yeeyi.com/bbs/forum.php?mod=viewthread&tid=12345678',
'User-Agent':'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_9_4) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/37.0.2062.120 Safari/537.36'
}
r = session.post('http://www.yeeyi.com/bbs/forum.php',params=param,data=data,headers=headers)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment