package scrape import ( "encoding/json" "fmt" "testing" "github.com/stretchr/testify/require" ) func TestParser(t *testing.T) { o := ParseFromJSON(html, `{ "title": "head > title", "headline": "body h1", "sections": { "#each": ".container", "head": "h2", "text": "p", "inner": { "#each": ".inner", "headline": "h3" }, "one": { "#element": ".one", "value": ".val" } } }`) require.Equal(t, o, nil) b, _ := json.MarshalIndent(o, "", " ") fmt.Println(string(b)) } func TestParser2(t *testing.T) { o := ParseFromJSON(html, `{ "#each": ".container", "head": "h2", "text": "p" }`) b, _ := json.MarshalIndent(o, "", " ") fmt.Println(string(b)) } var html = ` Title

Headline

Section 1

Paragraph 1

One

Inner H3

Inner H3 next

Section 2

Paragraph 2

Two

Inner H3 2

Inner H3 2 next

`