验证中...
本周日【珠海源创会】一起聊聊:PingCAP分布式事务、支付宝移动端实践、GSBN技术框架选型,点此报名占座
语言: Go
分类: 其他
最后更新于 2018-07-23 11:55
fundgz.go
原始数据 复制代码
func (jj *Fund) getGuZhi() *lastPriceData {
// Log.Debug("jj.txGZ", jj.txGZ)
gz := &lastPriceData{}
if jj.txGZ != nil {
gz.NavDate = jj.txGZ.NavDate
gz.Nav = jj.txGZ.Nav
}
jj.gz = gz
url := fmt.Sprintf("http://fundgz.1234567.com.cn/js/%s.js?rt=%d", jj.FundCode, time.Now().UnixNano() / int64(time.Millisecond))
// Log.Debug("url", url)
t1 := time.Now() // get current time
resp, err := httpClient.Get(url)
elapsed := time.Since(t1)
Log.Debug("App elapsed: ", elapsed)
if err != nil {
return gz
}
if resp.StatusCode != http.StatusOK {
return gz
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
// jsonpgz({"fundcode":"001052","name":"华夏中证500ETF联接","jzrq":"2018-02-06","dwjz":"0.6130","gsz":"0.6152","gszzl":"0.35","gztime":"2018-02-07 14:27"});
rawData := ttjGZRe.Find(body)
if rawData == nil {
return gz
}
m := map[string]string{}
err = json.Unmarshal(rawData, &m)
if err != nil {
Log.Debug("json Unmarshal", err)
return gz
}
gz.Name = m["name"]
navDate, err := time.ParseInLocation("2006-01-02", m["jzrq"], ZONE)
if err != nil {
Log.Warning("parse time err ")
}
if navDate.Unix() > gz.NavDate.Unix() {
gz.NavDate = navDate
gz.Nav, _ = strconv.ParseFloat(m["dwjz"], 64)
}
gz.NowPri, _ = strconv.ParseFloat(m["gsz"], 64)
gz.ChangePer, _ = strconv.ParseFloat(m["gszzl"], 64)
gztimeArr := strings.Split(m["gztime"], " ")
gz.GZTime = gztimeArr[1]
return gz
}

评论列表( 0 )

你可以在登录后,发表评论

搜索帮助

12_float_left_people 12_float_left_close