package main
import (
"encoding/json"
"fmt"
"io/ioutil"
"net/http"
)
type Node struct{
//属性
}
func main(){
//获取浏览器
resp,err:=http.Get("http://www.tianqiapi.com/api?version=v9&appid=23035354&appsecret=8YvlPNrz")
if err != nil{
fmt.Println("http get",err)
}
defer resp.Body.Close()
//读取字节(ioutil.ReadAll中读取所有字节)
resByte,err := ioutil.ReadAll(resp.Body)
if err != nil{
fmt.Println("read all io.read() fail",err)
}
//解析信息
node := &Node{}
err = json.Unmarshal(resByte,node)
//处理信息(node中的信息)...
}
获取网页信息并处理
最新推荐文章于 2024-05-13 04:30:55 发布