Skip to content

Instantly share code, notes, and snippets.

@5263
Last active August 29, 2015 14:07
Show Gist options
  • Save 5263/0269bcad57932323d10b to your computer and use it in GitHub Desktop.
Save 5263/0269bcad57932323d10b to your computer and use it in GitHub Desktop.
post on PHPBB forum
def phppost(subject,message,url,forum,username,password):
import mechanize
import time
br = mechanize.Browser()
br.open(url+'/ucp.php?mode=login')
loginform = tuple(br.forms())[1]
br.form=loginform
loginform.find_control("username").value=username
loginform.find_control("password").value=password
loginform.find_control("viewonline").set_single(True)
loginrespone = br.submit()
time.sleep(3)
br.open(url+('/posting.php?mode=post&f=%d' % forum))
postform = tuple(br.forms())[1]
postform.find_control("subject").value=subject
postform.find_control("message").value=message
postform.find_control("disable_bbcode").set_single(True)
postform.find_control("disable_smilies").set_single(True)
postform.find_control("disable_magic_url").set_single(True)
postform.find_control("save").disabled=True
postform.find_control("preview").disabled=True
postform.find_control("add_file").disabled=True
br.form= postform
time.sleep(3)
postreq = br.click(type="submit",name='post')
postresponse=br.open(postreq)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment