Godot i wanna get random kirby images from the web

Godot Version



I want to get all the web images containing Kirby in the form of a URL and display them randomly to the user.

Code Right Now

The variables are stored in an array.

var kirby_images:Array = [

Then I get a random image by

var rand_no = randi() % kirby_images.size()

According to this: HTTPRequest — Godot Engine (3.2) documentation in English, you can make an HTTP(s) request then use the result with load_png_from_buffer.

I am really new to godot i just want some sort of library which contains these images. I am using discord.gd to build a discord bot the problem is not showing the image but getting a ton of images.

var rand_no = randi() % kirby_images.size() 


bot.send(msg, {
  "embeds": [embed]

You could send a HTTP(s) GET request to a web scraper like this one: Google Images API - SerpApi then parse the results and pick a random image from the results.


Nice, i think this will do the trick.

1 Like

Hello I do not know how to get or extract data, as I said I have no experience in godot so do u have any tutorials or documentation lying around

Some useful docs:
HTTPRequest — Godot Engine (3.2) documentation in English
JSON — Godot Engine (3.2) documentation in English
Google Images API - SerpApi

Summing up the documentation:

  • use HTTPRequest.new() to create a HTTP(s) request node and add_child() to add it to your scene
  • my_https_node.connect("request_completed", self, "a_result_function") will call a function once it completes (in this case the place holder “a_result_function”)
  • the function declaration should look something like this: func a_result_function(result, response_code, headers, body):
  • you can use parse_json() to the parse the result string into a JSON object
    like this: var response = parse_json(body.get_string_from_utf8())
  • SerpApi can used like this https://serpapi.com/search.json?q=Kirby&engine=google_images&ijn=0&api_key=YOURKEY replace YOURKEY with a private SerpApi key. You can currently get a key for free.
1 Like