Hello,
I’ve seen a few subjects on the forum on how to search a Google Image and put the link in a google sheet (in order to display it as an image in Glide).
I found this query :
=TRANSPOSE(INDEX(QUERY(IMPORTXML(“https://www.google.com/search?q=“&B33&”&source=lnms&tbm=isch”; “//a//@src”);“where Col1 contains ‘image’ limit 2”)))
Where the “B33” is the element I want to search for on Google Images (can’t use Pexels because it’s mostly names of well known people).
My problem is to make it work in an arrayformula ; and from what I found it’s not possible, but it might with MAP.
I’ve come to this : =MAP(B:B;LAMBDA(n;{n\TRANSPOSE(QUERY(IMPORTXML(“https://www.google.com/search?q=“&B:B&”&source=lnms&tbm=isch”; “//a//@src”);“where Col1 contains ‘image’ limit 2”))}))
It does auto-fill the whole column, but it does it only for the first value of my B column, doesn’t compute all the lines.
Hope I’m clear and this can also be usefull for other people,
Thanks a lot !
SOLVED : I definitely wasn’t far : “just” needed to understand the Lambda function and give it another night.
To anyone wanting to use this, the right way to do is to change B:B in the query / importXML function to give it the first parameter given by MAP, which will be B1:B (or B:B) ‘inside’ of ‘n’. Just use this and you’ll be good :
=MAP(B:B;LAMBDA(n;{n\TRANSPOSE(QUERY(IMPORTXML(“https://www.google.com/search?q=“&n&”&source=lnms&tbm=isch”; “//a//@src”);“where Col1 contains ‘image’ limit 2”))}))