Skip to content

Instantly share code, notes, and snippets.

@uehaj
Created April 19, 2010 13:08
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save uehaj/371025 to your computer and use it in GitHub Desktop.
Save uehaj/371025 to your computer and use it in GitHub Desktop.
new GRubyScriptEngine().with {
require 'rubygems'
require 'mechanize'
def Mechanize = eval('WWW::Mechanize')
def a = Mechanize.new
a.basic_auth args[0], args[1]
def attachment_page = a.get('http://pukiwiki.example.com/pukiwiki.php?plugin=attach&pcmd=upload&page=sandbox')
def upload_form = attachment_page.form_with(method:"POST")
upload_form = upload_form
upload_form.pass = 'pass'
upload_form.file_uploads.first().file_name = args[2]
upload_form.submit
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment