How to crawl Tushare data and store it in mongodb

Obtaining data in tushare can be achieved through the tushare interface

First of all, to use the tushare interface, you must first install pymongo, json, and the tushare library

It can be installed with pip install tushare and the like

The calling interface code is directly provided on the tushare official website, find the data you want and paste the corresponding calling code into it

I use crawling the small and medium board classification as an example to illustrate

First, find the big title on the official website


Below it is the calling interface code


can be used directly


Then got the following data



You can select any one of them for crawling, taking the company named Xinhecheng as an example

Introduce pymongo with json and connect mongodb with Ipyhon

Get the data of Xinhecheng on February 22, 18 (code: 002001)


Create a tickdata table named db directory and insert the data


Finally, you can see the acquired data in mongodb campass



Although there is no data for this day. . . . .


Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325523520&siteId=291194637