How do I Get a random image from google/imgur/reddit?

Get help using Construct 2

Post » Thu Jan 07, 2016 9:39 am

I'd like to make a function that loads a random image into a sprite (possibly the thumbnail), how can I do that? Only one website is ok, I don't need to load the image from all them.

I'd like the image to be chosen from a specific search (example: only pictures with the keywoard 'mountain', or from the subreddit 'landscapes')

Maybe I know how to do that in python, but I'd like to try with construct 2, maybe with the help of a .js file.

Thank you in advance for your help.
Last edited by alessandrochl on Thu Jan 07, 2016 9:44 am, edited 1 time in total.
B
3
Posts: 2
Reputation: 181

Post » Thu Jan 07, 2016 9:43 am

There is the load image from url action?
Not sure if cross-domain requests are handled well though..

If you can do it from javascript, you might want to create a plugin for C2 to do it..
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Jan 07, 2016 9:45 am

Thank you, but I already know the load image from url action, the difficult part however is: "How do I get the url of a random image containing the keyword 'blablabla'?"
B
3
Posts: 2
Reputation: 181

Post » Thu Jan 07, 2016 9:51 am

I guess you'd need to implement something like the google search api in a construct plugin and have it return a random url..

https://developers.google.com/web-search/docs/

Using the forum search I also found this post:

andreyin wrote:It should be possible using the Sprite object, AJAX object and this plugin: plugin-json-import-export-generate-edit-inspect_t100042

Using Google's old image search API (found here https://developers.google.com/image-sea ... uide?hl=en) you can use AJAX to request a link with the search, parse it through the JSON parser plugin and then get the image links that you can use on the sprite object.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775


Return to How do I....?

Who is online

Users browsing this forum: stevenode, tarek2 and 10 guests