G
G
greque2019-03-07 19:27:31
go
greque, 2019-03-07 19:27:31

How to parse value between Golang tags?

I need to take the value between the tags from http.Response, for example , I need to get the value 143. <b id="userMoney">143</b>

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Alexander Pavlyuk, 2019-03-07
@pav5000

There is an excellent library that correctly parses html and allows you to select the necessary parts of it with css selectors.

G
greque, 2019-03-07
@greque

forSearch := `<b id="realmoney">`
start := strings.Index(pageContent, forSearch)
end := strings.Index(pageContent[start:], `</b>`)
value := pageContent[start+len(forSearch) : start+end]
fmt.Printf("Money: %v", value)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question