2019-08-04 23:25:47 +02:00
|
|
|
LET google = DOCUMENT("https://www.google.com/", {
|
|
|
|
driver: "cdp",
|
|
|
|
userAgent: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.87 Safari/537.36"
|
|
|
|
})
|
|
|
|
|
2020-06-17 23:37:01 +02:00
|
|
|
HOVER(google, 'input[name="q"]')
|
|
|
|
WAIT(RAND(100))
|
|
|
|
INPUT(google, 'input[name="q"]', @criteria, 30)
|
|
|
|
WAIT(RAND(100))
|
2019-08-04 23:25:47 +02:00
|
|
|
CLICK(google, 'input[name="btnK"]')
|
|
|
|
|
2021-09-02 17:09:48 +02:00
|
|
|
WAITFOR EVENT "navigation" IN google
|
|
|
|
|
|
|
|
WAIT_ELEMENT(google, "#res")
|
|
|
|
|
|
|
|
FOR el IN ELEMENTS(google, '#kp-wp-tab-overview > [jsdata]')
|
|
|
|
// filter out extra elements like media and 'People also ask'
|
|
|
|
FILTER ELEMENT_EXISTS(el, "#media_result_group") == FALSE
|
|
|
|
FILTER ELEMENT_EXISTS(el, '[role="heading"]') == FALSE
|
|
|
|
|
|
|
|
LET descr = (FOR i IN ELEMENTS(el, "span") FILTER LENGTH(i.attributes) == 0 RETURN i)
|
2019-08-04 23:25:47 +02:00
|
|
|
|
|
|
|
RETURN {
|
2021-09-02 17:09:48 +02:00
|
|
|
title: INNER_TEXT(el, 'h3'),
|
|
|
|
description: FIRST(descr),
|
|
|
|
url: ELEMENT(el, 'a')?.attributes.href
|
2019-08-04 23:25:47 +02:00
|
|
|
}
|