Skip to content

Instantly share code, notes, and snippets.

@Hamada92
Created August 31, 2023 14:38
Show Gist options
  • Save Hamada92/e65dac0fd35eb6bb377de4b43968d997 to your computer and use it in GitHub Desktop.
Save Hamada92/e65dac0fd35eb6bb377de4b43968d997 to your computer and use it in GitHub Desktop.
require "uri"
require "json"
require "net/http"
def recursive_fetch(url)
url = URI(url)
https = Net::HTTP.new(url.host, url.port)
https.use_ssl = true
request = Net::HTTP::Get.new(url)
request["Content-Type"] = "application/json"
response = https.request(request)
result = JSON.parse(response.read_body)
return result unless result["follow"]
new_url = result["follow"]
puts "following new linke #{new_url}"
return recursive_fetch(new_url.gsub("challenge", "challenge.json"))
end
recursive_fetch("https://www.letsrevolutionizetesting.com/challenge.json?id=756775492")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment