Skip to content

Instantly share code, notes, and snippets.

@aerphanas
Created January 2, 2023 06:14
Show Gist options
  • Select an option

  • Save aerphanas/88c5f257b4c7477dff890529434dffdc to your computer and use it in GitHub Desktop.

Select an option

Save aerphanas/88c5f257b4c7477dff890529434dffdc to your computer and use it in GitHub Desktop.
generate a tuple that contains the number of verses of the Koran
require "http/client"
require "json"
url = "https://quranapi.idn.sch.id/surah/"
target = 114
print "{"
target.times do | x |
request = HTTP::Client.get(url + (x+1).to_s)
response = JSON.parse(request.body)["numberOfAyahs"]
print response.to_s + if (x == target-1) "" else ", " end
end
puts "}"
# out :
# {7, 286, 200, 176, 120, 165, 206, 75, 129, 109, 123, 111, 43, 52, 99, 128, 111, 110, 98, 135, 112, 78, 118, 64, 77, 227, 93, 88, 69, 60, 34, 30, 73, 54, 45, 83, 182, 88, 75, 85, 54, 53, 89, 59, 37, 35, 38, 29, 18, 45, 60, 49, 62, 55, 78, 96, 29, 22, 24, 13, 14, 11, 11, 18, 12, 12, 30, 52, 52, 44, 28, 28, 20, 56, 40, 31, 50, 40, 46, 42, 29, 19, 36, 25, 22, 17, 19, 26, 30, 20, 15, 21, 11, 8, 8, 19, 5, 8, 8, 11, 11, 8, 3, 9, 5, 4, 7, 3, 6, 3, 5, 4, 5, 6}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment