V
V
vadimuar2019-04-20 14:45:05
go
vadimuar, 2019-04-20 14:45:05

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

2 answer(s)
D
Dasha Tsiklauri, 2019-04-20
@dasha_programmist

here is either fire, what you need
https://github.com/PuerkitoBio/goquery

V
vadimuar, 2019-04-20
@vadimuar

My code for this.
Thanks GLaDosSystem.

code
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 question

Ask a Question

731 491 924 answers to any question