static BufferedImage googleImageSearchFirst(S q) { JWindow w = loadingAnim("Googling image: " + q); try { S html = str(googleImageSearch_loadPage(q)); S id = regexpFirstGroup("\"id\":\"(..............):\"", html); if (id == null) null; print("Image search: ID=" + id); S s = regexpFirstGroup("\\[\"" + id + ":\",\"data:image/(?:png|jpeg|gif);base64,([^\"]+)", html); if (s == null) { print("Image search: ID not found. Saving debug"); saveTextFile(prepareProgramFile(#1007145, "debug.html"), html); null; } try { ret decodeImage(base64decode(unquote("\"" + s + "\""))); } on fail { print("Tried to decode: " + quote(s)); } } finally { disposeWindow(w); } }