Example #1
0
// shanghaiCompanies 上海证券交易所上市公司
func (m China) shanghaiCompanies() ([]Company, error) {

	urls := [...]string{
		"http://query.sse.com.cn/security/stock/downloadStockListFile.do?csrcCode=&stockCode=&areaName=&stockType=1",
		"http://query.sse.com.cn/security/stock/downloadStockListFile.do?csrcCode=&stockCode=&areaName=&stockType=2",
	}
	referer := "http://www.sse.com.cn/assortment/stock/list/share/"

	var list []Company
	for _, url := range urls {

		//	尝试从网络获取实时上市公司列表
		text, err := net.DownloadStringRefererRetry(url, referer, retryTimes, retryIntervalSeconds)
		if err != nil {
			return nil, err
		}

		//	解析json
		companies, err := m.parseShanghaiJSON(text)
		if err != nil {
			return nil, err
		}

		list = append(list, companies...)
	}

	return list, nil
}
Example #2
0
//	上海证券交易所上市公司
func (m China) shanghaiCompanies() ([]Company, error) {

	urls := [...]string{
		"http://query.sse.com.cn/commonQuery.do?isPagination=false&sqlId=COMMON_SSE_ZQPZ_GPLB_MCJS_SSAG_L",
		"http://query.sse.com.cn/commonQuery.do?isPagination=false&sqlId=COMMON_SSE_ZQPZ_GPLB_MCJS_SSBG_L",
	}
	referer := "http://www.sse.com.cn/assortment/stock/list/name/"

	list := make([]Company, 0)
	for _, url := range urls {

		//	尝试从网络获取实时上市公司列表
		json, err := net.DownloadStringRefererRetry(url, referer, retryTimes, retryIntervalSeconds)
		if err != nil {
			return nil, err
		}

		//	解析json
		companies, err := m.parseShanghaiJson(json)
		if err != nil {
			return nil, err
		}

		list = append(list, companies...)
	}

	return list, nil
}