コード例 #1
0
ファイル: stock_struct.py プロジェクト: guoweiweiviv/stocks
    # 	print data.encode("utf8")

    return data


def save_stock_struct(stock_code, data, dir):
    file_name = dir + "/" + stock_code
    file = open(file_name, "w")
    file.write(data)
    file.close()


web = "http://f10.eastmoney.com/f10_v2/CapitalStockStructure.aspx?code=sz000001"
save_dir = "../../../data/stock_struct/eastmoney"
if __name__ == "__main__":
    stocks = read_stock("sh")
    print len(stocks)
    # 	for k,v in stocks.items():
    # 		url = "http://f10.eastmoney.com/f10_v2/CapitalStockStructure.aspx?code=sh{0}".format(k)
    # 		print url
    # 		save(k, get_stock_struct(k, url), save_dir)
    #
    stocks = read_stock("sz")
    print len(stocks)
    i = 0
    for k, v in stocks.items()[500:]:
        url = "http://f10.eastmoney.com/f10_v2/CapitalStockStructure.aspx?code=sz{0}".format(k)
        print i, url
        save(k, get_stock_struct(k, url), save_dir)

        i += 1
コード例 #2
0
ファイル: stock_struct.py プロジェクト: genliu777/stocks
    #	print data.encode("utf8")

    return data


def save_stock_struct(stock_code, data, dir):
    file_name = dir + "/" + stock_code
    file = open(file_name, "w")
    file.write(data)
    file.close()


web = "http://f10.eastmoney.com/f10_v2/CapitalStockStructure.aspx?code=sz000001"
save_dir = "../../../data/stock_struct/eastmoney"
if __name__ == "__main__":
    stocks = read_stock("sh")
    print len(stocks)
    #	for k,v in stocks.items():
    #		url = "http://f10.eastmoney.com/f10_v2/CapitalStockStructure.aspx?code=sh{0}".format(k)
    #		print url
    #		save(k, get_stock_struct(k, url), save_dir)
    #
    stocks = read_stock("sz")
    print len(stocks)
    i = 0
    for k, v in stocks.items()[500:]:
        url = "http://f10.eastmoney.com/f10_v2/CapitalStockStructure.aspx?code=sz{0}".format(
            k)
        print i, url
        save(k, get_stock_struct(k, url), save_dir)
コード例 #3
0
	finally:
		pass

def wget2(url):
	try:
		buf = cStringIO.StringIO()

		c = pycurl.Curl()
		c.setopt(c.URL, url)
		c.setopt(pycurl.USERAGENT, "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0")
		c.setopt(c.WRITEFUNCTION, buf.write)
		c.perform()

		s = buf.getvalue()
		buf.close()
		return s
	finally:
		pass

	return None
	
if __name__ == "__main__":
	stocks = read_stock("sz")
	i=0
	for k,v in stocks.items()[700:]:
		print i, v[0], v[1]
		url = "http://xueqiu.com/S/SZ{0}/historical.csv".format(v[0])
#		url = "http://real-chart.finance.yahoo.com/table.csv?s={0}.SS&ignore=.csv".format(v[0])
		wget(url, "../../../data/price/sz/xueqiu/{0}".format(v[0]))
		i += 1
コード例 #4
0
    try:
        buf = cStringIO.StringIO()

        c = pycurl.Curl()
        c.setopt(c.URL, url)
        c.setopt(
            pycurl.USERAGENT,
            "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:40.0) Gecko/20100101 Firefox/40.0"
        )
        c.setopt(c.WRITEFUNCTION, buf.write)
        c.perform()

        s = buf.getvalue()
        buf.close()
        return s
    finally:
        pass

    return None


if __name__ == "__main__":
    stocks = read_stock("sz")
    i = 0
    for k, v in stocks.items()[700:]:
        print i, v[0], v[1]
        url = "http://xueqiu.com/S/SZ{0}/historical.csv".format(v[0])
        #		url = "http://real-chart.finance.yahoo.com/table.csv?s={0}.SS&ignore=.csv".format(v[0])
        wget(url, "../../../data/price/sz/xueqiu/{0}".format(v[0]))
        i += 1