def demo_reporthook(downloaded, total_size):
print("Downloaded {}, Total is {}".format(downloaded, total_size))
获取历史专业财务数据列表 pytdx.crawler.HistoryFinancialListCrawler
from pytdx.crawler.history_financial_crawler import HistoryFinancialListCrawler
crawler = HistoryFinancialListCrawler()
list_data = crawler.fetch_and_parse()
print(pd.DataFrame(data=list_data))
In [8]: print(pd.DataFrame(data=list_data))
filename filesize hash
0 gpcw20171231.zip 49250 0370b2703a0e23b4f9d87587f4a844cf
1 gpcw20170930.zip 2535402 780bc7c649cdce35567a44dc3700f4ce
2 gpcw20170630.zip 2739127 5fef91471e01ebf9b5d3628a87d1e73d
3 gpcw20170331.zip 2325626 a9bcebff37dd1d647f3159596bc2f312
4 gpcw20161231.zip 2749415 3fb3018c235f6c9d7a1448bdbe72281a
5 gpcw20160930.zip 2262567 8b629231ee9fad7e7c86f1e683cfb489
.. ... ... ...
75 gpcw19971231.zip 434680 316ce733f2a4f6b21c7865f94eee01c8
76 gpcw19970630.zip 196525 6eb5d8e5f43f7b19d756f0a2d91371f5
77 gpcw19961231.zip 363568 bfd59d42f9b6651861e84c483edb499b
78 gpcw19960630.zip 122145 18023e9f84565323874e8e1dbdfb2adb
[79 rows x 3 columns]
获取历史专业财务数据内容 pytdx.crawler.HistoryFinancialCrawler
from pytdx.crawler.base_crawler import demo_reporthook
from pytdx.crawler.history_financial_crawler import HistoryFinancialCrawler
datacrawler = HistoryFinancialCrawler()
pd.set_option('display.max_columns', None)
result = datacrawler.fetch_and_parse(reporthook=demo_reporthook, filename='gpcw19971231.zip', path_to_download="/tmp/tmpfile.zip")
print(datacrawler.to_df(data=result))
from pytdx.reader import HistoryFinancialReader
print(HistoryFinancialReader().get_df('/tmp/gpcw20170930.dat'))
-->rainx@JingdeMacBook-Pro:/tmp$ hqreader -d hf -o /tmp/gpcw20170930.csv /tmp/gpcw20170930.dat
写入到文件 : /tmp/gpcw20170930.csv