Answer the question
In order to leave comments, you need to log in
How to parse information from a site on GO and find a specific phrase?
Hello, I need to make a golang script that will go to a certain page on the Internet and search for a certain text on it. If it finds that one condition is fulfilled, if it does not find it, then another. I can't understand the implementation principle, tell me please :3
Answer the question
In order to leave comments, you need to log in
here is either fire, what you need
https://github.com/PuerkitoBio/goquery
My code for this.
Thanks GLaDosSystem.
package main
import (
"fmt"
"io/ioutil"
"log"
"net/http"
"regexp"
)
func main() {
resp, err := http.Get("LINK")
if err != nil {
log.Fatalln(err)
}
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
log.Fatalln(err)
}
tm, err := regexp.Match("TEXT", []byte(body))
if tm {
fmt.Println("true")
} else {
fmt.Println("false")
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question