Skip to content

Instantly share code, notes, and snippets.

@kaixiang-li
Created February 4, 2012 05:24
Show Gist options
  • Save kaixiang-li/1735577 to your computer and use it in GitHub Desktop.
Save kaixiang-li/1735577 to your computer and use it in GitHub Desktop.
using mechanize to send a fanfou message
# encoding: utf-8
require "rubygems"
require "mechanize"
agent = Mechanize.new
page = agent.get("http://fanfou.com/")
login_form = page.form
login_form.loginname = "username"
login_form.loginpass = "password"
home_page = agent.submit(login_form,login_form.buttons.first)
home_page_form = home_page.form
home_page_form.content = "mechanize test"
agent.submit(home_page_form,home_page_form.buttons.first)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment