Compare commits

...

2 Commits

Author SHA1 Message Date
独孤伶俜 619a2a8929 Merge remote-tracking branch 'origin/master' 2022-12-14 22:43:48 +08:00
独孤伶俜 62a52095d1 day8方法 2022-12-14 22:43:28 +08:00
1 changed files with 2 additions and 2 deletions

View File

@ -24,7 +24,7 @@ func title(url string) error {
}
// 直到包含defer的函数执行完毕之后defer的这条语句才会执行
defer resp.Body.Close()
// Check Content-Type is HTML (e.g., "text/html;charset=utf-8").
// Check Content-Type is Html (e.g., "text/html;charset=utf-8").
ct := resp.Header.Get("Content-Type")
if ct != "text/html" && !strings.HasPrefix(ct, "text/html;") {
return fmt.Errorf("%s has type %s, not text/html", url, ct)
@ -32,7 +32,7 @@ func title(url string) error {
doc, err := html.Parse(resp.Body)
if err != nil {
return fmt.Errorf("parsing %s as HTML: %v", url, err)
return fmt.Errorf("parsing %s as Html: %v", url, err)
}
visitNode := func(n *html.Node) {
if n.Type == html.ElementNode && n.Data == "title" && n.FirstChild != nil {