Skip to content

Instantly share code, notes, and snippets.

@zachbonham
Created April 9, 2010 02:33
Show Gist options
  • Save zachbonham/360818 to your computer and use it in GitHub Desktop.
Save zachbonham/360818 to your computer and use it in GitHub Desktop.
1:1 between ruby and C# for getsmarx
require 'rexml/document'
require 'rexml/xpath'
require 'net/http'
require 'net/https'
require 'uri'
include REXML
url = URI.parse('http://annoysmarx.cloudapp.net/')
data = Net::HTTP.start(url.host, url.port) { |http|
http.get('/')
}
xml = Document.new data.body
anchors = XPath.match(xml, "//a/@href")
baseuri = anchor.value[0,"https://annoysmarx.servicebus.windows.net".length]
request = anchor.value["https://annoysmarx.servicebus.windows.net".length, anchor.value.length]
url = URI.parse(baseuri)
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
data = http.get(request)
puts data
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment