Warning: session_start(): open(/var/lib/php/sessions/sess_45s6fecn6f6m9pb2lifu3euj9c, O_RDWR) failed: No space left on device (28) in /var/www/tb-usercake/models/config.php on line 51
Warning: session_start(): Failed to read session data: files (path: /var/lib/php/sessions) in /var/www/tb-usercake/models/config.php on line 51
scope googleImageSearch_new.
lib 1002510 // jsoup
import org.jsoup.*;
import org.jsoup.nodes.*;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
import org.jsoup.select.Elements;
static S #userAgent = "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.1";
static int #timeout = 10*1000;
static BufferedImage googleImageSearch_new(S q) {
S html = loadPage_cached(q);
S group = regexpFirstGroup("image/jpeg;base64,([a-zA-Z0-9/+]*)={0,2}", html);
ret group == null ? null
: imageFromBytes(base64decode(dropLast(l(group) & 3, group)));
}
sS #loadPage_cached(S q) {
File f = googleImageSearch_htmlCacheFile(q);
if (fileSize(f) > 0) ret loadTextFile(f);
S html = str(loadPage(q));
saveTextFile(f, html);
ret html;
}
static Document #loadPage(S q) ctex {
S googleUrl = "https://www.google.com/search?tbm=isch&safe=active&q=" + urlencode(q);
print("Googling " + quote(q));
ret Jsoup.connect(googleUrl).userAgent(#userAgent).timeout(#timeout).get();
}
end scope