Created
April 9, 2010 02:33
-
-
Save zachbonham/360818 to your computer and use it in GitHub Desktop.
1:1 between ruby and C# for getsmarx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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