File tree Expand file tree Collapse file tree 3 files changed +18
-32
lines changed
Expand file tree Collapse file tree 3 files changed +18
-32
lines changed Original file line number Diff line number Diff line change 88 " gohtml" ,
99 " Kottue" ,
1010 " linkedliststack" ,
11+ " println" ,
1112 " yosssi"
1213 ]
1314}
Original file line number Diff line number Diff line change 1- ## v0.0.3
2- - Write test for (closest, QuerySelector, QuerySelectorAll)
3- - Serializer bug fix
4-
5- ## TODO
6- * Update the the readme example and change the CHANGELOG
71
Original file line number Diff line number Diff line change @@ -26,36 +26,27 @@ import (
2626- Querying
2727
2828## Example
29+
2930Heres an example of fetching a website and parsing and then using querying methods.
31+
3032``` go
31- res , err := http.Get (" https://www.metalsucks.net/" )
32- if err != nil {
33- t.Fatal (err)
34- }
35- defer res.Body .Close ()
36-
37- // Parses the given html reader and then returns the root node and an error.
38- node , err := GoHtml .Decode (res.Body )
39- if err != nil {
40- t.Fatal (err)
41- }
42-
43- nodeList := node.GetElementsByClassName (" post-title" )
44- iter := nodeList.IterNodeList ()
45- for node := range iter{
46- print (node.GetInnerText ())
47- }
33+ res , err := http.Get (" https://www.metalsucks.net/" )
34+ if err != nil {
35+ t.Fatal (err)
36+ }
37+ defer res.Body .Close ()
38+
39+ node , err := GoHtml .Decode (res.Body )
40+ if err != nil {
41+ t.Fatal (err)
42+ }
43+
44+ nodeList := node.QuerySelectorAll (" .left-content article .post-title" )
45+ for node := range nodeList.IterNodeList (){
46+ println (node.GetInnerText ())
47+ }
4848```
4949
50- ## Changelog
51-
52- Changes, bug fixes and new features in this version.
53- - add: Closest
54- - add: QuerySearch
55- - add: QuerySelector
56- - add: QuerySelectorAll
57- - renamed: Tokenizer CurrentNode method to GetCurrentNode.
58-
5950## Documentation
6051
6152Fully fledged [ documentation] ( https://pkg.go.dev/github.com/udan-jayanith/GoHTML ) is available at [ go.pkg] ( https://pkg.go.dev/ )
You can’t perform that action at this time.
0 commit comments