27 lines
449 B
Go
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
|
|
}
|