Warning: session_start(): open(/var/lib/php/sessions/sess_nbre61v4lc9e1qo6as4m4djnrt, 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
!7
p {
S query = "gramophone";
S userAgent = "Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:53.0) Gecko/20100101 Firefox/53.0";
S html = loadPageWithUserAgent("http://google.com/search?q=" + urlencode(query) + "&lr=lang_en&hl=en", userAgent);
S url = first(loadPage_responseHeaders->get("Location"));
if (url != null)
html = loadPageWithUserAgent(url, userAgent);
//print(html);
pnlStruct(loadPage_responseHeaders!);
// Every h3 is a search result
L htmlTok = htmlTok(html);
LL h3s = findContainerTagDeep(htmlTok, "h3");
pnlStruct(h3s);
for (L tok : h3s) {
L linkTok = first(findContainerTag(tok, "a"));
if (empty(linkTok)) continue;
S link = tagGet(second(linkTok), "href");
S text = join(dropTags(contentsOfContainerTag(linkTok)));
L sub = subList(htmlTok, magicIndexOfSubList(htmlTok, tok)+l(tok)-1);
S desc = trimJoin(first(findContainerTagWithParams(sub, "span", "class" := "st")));
print("Link: " + link);
print(" Text: " + text);
print(" Desc: " + desc);
}
}