We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
給定一個網址 抓取該網址全部文字內容 透過 ChatGPT 給出摘要
The text was updated successfully, but these errors were encountered:
refer code
package main import ( "fmt" "net/http" "golang.org/x/net/html" "strings" ) func main() { url := "https://www.example.com" resp, err := http.Get(url) if err != nil { fmt.Println("Error retrieving the URL:", err) return } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { fmt.Println("Error status code:", resp.StatusCode) return } doc, err := html.Parse(resp.Body) if err != nil { fmt.Println("Error parsing HTML:", err) return } var textContent func(*html.Node) textContent = func(n *html.Node) { if n.Type == html.TextNode { text := strings.TrimSpace(n.Data) if text != "" { fmt.Println(text) } } for c := n.FirstChild; c != nil; c = c.NextSibling { textContent(c) } } textContent(doc) }
Sorry, something went wrong.
kkdai
No branches or pull requests
給定一個網址
抓取該網址全部文字內容
透過 ChatGPT 給出摘要
The text was updated successfully, but these errors were encountered: