shad-go/lectures/01-basics/countwords/main.go
2020-02-20 17:40:51 +03:00

27 lines
449 B
Go

package main
import (
"fmt"
"net/http"
"golang.org/x/net/html"
)
func CountWordsAndImages(url string) (words, images int, err error) {
resp, err := http.Get(url)
if err != nil {
return
}
doc, err := html.Parse(resp.Body)
resp.Body.Close()
if err != nil {
err = fmt.Errorf("parsing HTML: %s", err)
return
}
words, images = countWordsAndImages(doc)
return
}
func countWordsAndImages(n *html.Node) (words, images int) {
return
}