gitee.com/quant1x/engine@v1.8.4/market/shse/sse_index.go (about)

     1  package shse
     2  
     3  import (
     4  	"fmt"
     5  	"gitee.com/quant1x/gox/http"
     6  	"math"
     7  	"math/rand"
     8  	urlpkg "net/url"
     9  	"time"
    10  )
    11  
    12  const (
    13  	// http://www.sse.com.cn/market/sseindex/indexlist/
    14  	urlSSEIndex = "https://query.sse.com.cn/commonSoaQuery.do"
    15  	//urlSSEIndex = "http://query.sse.com.cn/commonQuery.do"
    16  )
    17  
    18  // IndexList 上海指数列表
    19  func IndexList() {
    20  	//isPagination=false&sqlId=DB_SZZSLB_ZSLB&_=1682986576599
    21  	now := time.Now()
    22  	timestamp := now.UnixMilli()
    23  	cbNum := int(math.Floor(rand.Float64() * (100000000 + 1)))
    24  	// 37039113
    25  	params := urlpkg.Values{
    26  		"jsonCallBack": {fmt.Sprintf("jsonpCallback%d", cbNum)},
    27  		"isPagination": {"false"},
    28  		"sqlId":        {"DB_SZZSLB_ZSLB"},
    29  		"_":            {fmt.Sprintf("%d", timestamp)},
    30  	}
    31  	header := map[string]any{
    32  		"Referer": "http://www.sse.com.cn/",
    33  		//"Cookie":  "ba17301551dcbaf9_gdp_user_key=; gdp_user_id=gioenc-1aadbe52,d720,54c2,9271,29b7b6dda362; ba17301551dcbaf9_gdp_session_id_2960a971-ddff-48be-827f-6eb99e891735=true; ba17301551dcbaf9_gdp_session_id_4602911b-d360-4f09-a438-3d40bca228d7=true; ba17301551dcbaf9_gdp_session_id_86910507-dd22-4b31-9749-e3a3b18eae25=true; ba17301551dcbaf9_gdp_session_id_1bb67914-f729-4e41-b75c-d09a6b0d7873=true; JSESSIONID=7052255EE4B2357019E75B7B09D6D571; ba17301551dcbaf9_gdp_session_id=2a1f157c-1605-45e8-a68b-e4196d04b2af; ba17301551dcbaf9_gdp_session_id_2a1f157c-1605-45e8-a68b-e4196d04b2af=true; ba17301551dcbaf9_gdp_sequence_ids={\"globalKey\":42,\"VISIT\":6,\"PAGE\":14,\"VIEW_CHANGE\":2,\"CUSTOM\":3,\"VIEW_CLICK\":21}",
    34  	}
    35  	url := urlSSEIndex + "?"
    36  	//url += fmt.Sprintf("jsonCallBack=jsonpCallback%d&", cbNum)
    37  	//url += "isPagination=false&"
    38  	//url += "sqlId=DB_SZZSLB_ZSLB&"
    39  	url += params.Encode()
    40  	data, tm, err := http.Request(url, "get", header)
    41  	fmt.Println(string(data), tm, err)
    42  
    43  }