mirror of
https://github.com/MontFerret/ferret.git
synced 2025-01-04 03:02:02 +02:00
#26 implemented INPUT
This commit is contained in:
parent
8b2e210317
commit
f43d6fe870
@ -1,7 +1,7 @@
|
|||||||
LET g = DOCUMENT("https://www.google.com/", true)
|
LET g = DOCUMENT("https://www.google.com/", true)
|
||||||
LET inputBox = ELEMENT(g, 'input[name="q"]')
|
LET inputBox = ELEMENT(g, 'input[name="q"]')
|
||||||
|
|
||||||
INPUT(inputBox, "ferrer")
|
INPUT(inputBox, "ferret")
|
||||||
|
|
||||||
LET searchBtn = ELEMENT(g, 'input[name="btnK"]')
|
LET searchBtn = ELEMENT(g, 'input[name="btnK"]')
|
||||||
|
|
||||||
@ -9,16 +9,17 @@ CLICK(searchBtn)
|
|||||||
|
|
||||||
WAIT_NAVIGATION(g)
|
WAIT_NAVIGATION(g)
|
||||||
|
|
||||||
LET result = ELEMENTS(g, '.g')
|
LET result = (
|
||||||
|
|
||||||
LOG(result ? 'element' : 'no element')
|
|
||||||
|
|
||||||
RETURN result ? (
|
|
||||||
FOR result IN ELEMENTS(g, '.g')
|
FOR result IN ELEMENTS(g, '.g')
|
||||||
LOG('iterate')
|
RETURN {
|
||||||
RETURN {
|
title: ELEMENT(result, 'h3 > a'),
|
||||||
title: ELEMENT(result, 'h3 > a'),
|
description: ELEMENT(result, '.st'),
|
||||||
description: ELEMENT(result, '.st'),
|
url: ELEMENT(result, 'cite')
|
||||||
url: ELEMENT(result, 'cite')
|
}
|
||||||
}
|
)
|
||||||
) : 'no results'
|
|
||||||
|
RETURN (
|
||||||
|
FOR i IN result
|
||||||
|
FILTER i.title != NONE
|
||||||
|
RETURN i
|
||||||
|
)
|
@ -5,6 +5,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"crypto/sha512"
|
"crypto/sha512"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
"github.com/MontFerret/ferret/pkg/runtime/core"
|
"github.com/MontFerret/ferret/pkg/runtime/core"
|
||||||
"github.com/MontFerret/ferret/pkg/runtime/values"
|
"github.com/MontFerret/ferret/pkg/runtime/values"
|
||||||
"github.com/MontFerret/ferret/pkg/stdlib/html/driver/common"
|
"github.com/MontFerret/ferret/pkg/stdlib/html/driver/common"
|
||||||
@ -161,9 +162,6 @@ func (el *HtmlElement) Type() core.Type {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (el *HtmlElement) MarshalJSON() ([]byte, error) {
|
func (el *HtmlElement) MarshalJSON() ([]byte, error) {
|
||||||
el.Lock()
|
|
||||||
defer el.Unlock()
|
|
||||||
|
|
||||||
val, err := el.innerText.Value()
|
val, err := el.innerText.Value()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user