Skip to content

Instantly share code, notes, and snippets.

@kubido
Created August 24, 2021 12:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kubido/6ecc3d708ce6e7994269060311785540 to your computer and use it in GitHub Desktop.
Save kubido/6ecc3d708ce6e7994269060311785540 to your computer and use it in GitHub Desktop.
halodoc hospitals scrapper
require('Faraday')
require('json')
def fetch_hospitals(page=1)
url = "https://www.halodoc.com/api/rumah-sakit/v1/hospitals/search"
params = { page_no: page, per_page: 20 }.to_json
headers = { "Content-Type": "application/json"}
response = Faraday.put(url, params, headers)
return JSON.parse(response.body)
end
current_page = 1
end_page = false
while !end_page
data = fetch_hospitals(current_page)
current_page += 1
puts current_page
end_page = data['next_page'] == "false"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment