In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Internet Technology >
Share
Shulou(Shulou.com)06/01 Report--
Editor to share with you go how to climb the eth price, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!
Package main
Import (
"encoding/json"
"fmt"
"github.com/PuerkitoBio/goquery"
"net/http"
"strconv"
"strings"
)
Func main () {
Var (
Res * http.Response
Reqest * http.Request
Client = & http.Client {}
Err error
)
Reqest, err = http.NewRequest ("POST", "http://srh.bankofchina.com/search/whpj/search.jsp", strings.NewReader (" pjname=1316 "))
Reqest.Header.Add ("User-Agent", "Mozilla/5.0 (X11; Fedora; Linux x86, 64) AppleWebKit/537.36 (KHTML, like" +
"Gecko) Chrome/73.0.3683.75 Safari/537.36")
Reqest.Header.Set ("Content-Type", "application/x-www-form-urlencoded")
Reqest.Header.Add ("Referer", "http://www.boc.cn/sourcedb/whpj/")"
Reqest.Header.Add ("Origin", "http://srh.bankofchina.com")"
Reqest.Header.Add ("Cookie", "JSESSIONID=0000poVLE_MQLZrCgwhZtvexMYX:-1")
Reqest.Header.Add ("Accept", "text/html,application/xhtml+xml,application/xml;q=0.9," +
"image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3")
Reqest.Header.Add ("Host", "srh.bankofchina.com")
If res, err = client.Do (reqest); err! = nil {
Return
}
Defer res.Body.Close ()
Test ()
}
Func test () {
Var (
Doc * goquery.Document
)
Resp, err: = http.Get ("https://www.feixiaohao.com/currencies/ethereum/")
If err! = nil {
/ / handle error
}
Defer resp.Body.Close ()
If doc, err = goquery.NewDocumentFromReader (resp.Body); err! = nil {
Return
}
/ / ll: = doc.Find (`.priceInfo .convert`) .Text ()
/ / fmt.Println (ll)
Doc.Find (`.priceInfo`) .Each (func (I int, selection * goquery.Selection) {
T: = selection.Find (".convert") .Text ()
Fmt.Println (t)
A: = "
For _ I, v: = range t {
If string (v) = "$" {
A = t [: _ I]
}
}
Fmt.Println (a)
})
}
Func priGetEthPrice () (ret float64, err error) {
Var (
Url = "http://api.zb.cn/data/v1/ticker?market=eth_usdt"
Resp * http.Response
Doc * goquery.Document
Data float64
)
/ / obtain data
If resp, err = http.Get (url); err = nil {
Defer resp.Body.Close ()
} else {
Return
}
/ / parsing parameters
If doc, err = goquery.NewDocumentFromReader (resp.Body); err! = nil {
Return
}
Var d * struct {
Ticker struct {
Buy string `json: "buy" `
}
}
If err = json.Unmarshal ([] byte (doc.Text ()), & d); err! = nil {
Return
}
If data, err = strconv.ParseFloat (d.Ticker.Buy, 64); err! = nil {
Return
}
Ret = data
Return
}
The above is all the contents of the article "how go crawls eth prices". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.