ruby pastebin

Posted by Anonymous on Wed 2nd Dec 22:51 (modification of post by view diff)
download | new post

  1.   def forum(text)
  2.     agent = WWW::Mechanize.new
  3.  
  4.     # login
  5.     page = agent.get @forum['url']
  6.     form = page.forms.select { |form| form.action == "#{@forum['url']}?action=login2" }.first
  7.     form.user, form.passwrd = @forum['username'], @forum['password']
  8.     page = agent.submit form, form.buttons.first
  9.  
  10.     # modify topic
  11.     page = agent.get "#{@forum['url']}?topic=#{@forum['id']}"
  12.     page = agent.click page.links.select { |link| link.text == 'Modify' }.first
  13.     form = page.form 'postmodify'
  14.     if form.message == text
  15.       return :unchanged
  16.     end
  17.     form.message = text
  18.     page = agent.submit form, form.buttons.first
  19.     return :success
  20.   end

Submit a correction or amendment below (click here to make a fresh posting)
After submitting an amendment, you'll be able to view the differences between the old and new posts easily.

Syntax highlighting:

To highlight particular lines, prefix each line with @@


I'm Human
Remember me



Captcha required for posting