Skip to content

Instantly share code, notes, and snippets.

@tenderlove
Created February 8, 2011 20:14
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tenderlove/817127 to your computer and use it in GitHub Desktop.
Save tenderlove/817127 to your computer and use it in GitHub Desktop.
require 'net/http'
require 'rubygems'
require 'nokogiri'
url = URI.parse 'http://memegenerator.net/Instance/CreateOrEdit'
res = Net::HTTP.post_form(url, {
'templateType' => 'AdviceDogSpinoff',
'text0' => ARGV[0],
'text1' => ARGV[1],
'templateID' => '165241',
'generatorName' => 'Y-U-NO'
})
location = res['Location']
res = Net::HTTP.start(url.host, url.port) { |http|
http.get location
}
doc = Nokogiri.HTML res.body
puts doc.css("a[href=\"#{location}\"] img").first['src']
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment