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)
|
2019-08-04 23:25:47 +02:00
|
|
|
|
2020-06-17 23:37:01 +02:00
|
|
|
WAIT(RAND(100))
|
|
|
|
|
|
|
|
WAIT_ELEMENT(google, '.UUbT9')
|
|
|
|
WAIT(RAND(100))
|
2019-08-04 23:25:47 +02:00
|
|
|
CLICK(google, 'input[name="btnK"]')
|
|
|
|
|
|
|
|
WAIT_NAVIGATION(google)
|
|
|
|
|
|
|
|
FOR result IN ELEMENTS(google, '.g')
|
|
|
|
// filter out extra elements like videos and 'People also ask'
|
|
|
|
FILTER TRIM(result.attributes.class) == 'g'
|
|
|
|
RETURN {
|
|
|
|
title: INNER_TEXT(result, 'h3'),
|
2020-11-21 03:09:21 +02:00
|
|
|
description: INNER_TEXT(result, '.rc > div:nth-child(2) span'),
|
2019-08-04 23:25:47 +02:00
|
|
|
url: INNER_TEXT(result, 'cite')
|
|
|
|
}
|