由于各大虚拟币交易平台更多地显示自己平台上的虚拟币交易信息,如果想同时看不同平台上的虚拟币交易情况时,就要打开很多页面而且需要不停地切换页面,操作非常不方便,于是就想着做一款工具,能实时显示当前不同虚拟币交易所的价格方便操作。
As the virtual currency trading platforms show more information about virtual currency transactions on their own platforms, when looking at virtual currency transactions on different platforms at the same time, many pages are opened and require constant page switching, which is extremely unwieldy, and the idea is to work as a tool to show in real time the price ease of the different virtual currency exchanges that are currently taking place.
开始的计划是,分别调用自己感兴趣的平台提供的API,以获取当前不同币种的当前价格,但是在进行编程的时候,遇到一些困难:
The initial plan was to use the API provided by a platform of interest to obtain current prices in different current currencies, but some difficulties were encountered in programming:
1、获取速度问题:比如当需要获取比特币在不同平台上的价格信息时,就要分别访问各个平台的API,想要获取5个交易平台的比特币价格时,就要分别获取5次,当如果增加币种,比如莱特币,以太坊等时,访问的次数就会成倍增长,一个简单的公式:访问次数(s)=平台数(n) × 币种数(m),这样效率非常低下;
1. The question of speed of access: for example, when it is necessary to obtain price information for Bitcoin on different platforms, it is necessary to visit the API of each platform separately, five times when it is necessary to obtain the price of bitcoin for each of the five trading platforms, and when the number of visits is multiplied, e.g., when the currency is increased, e.g., Leitco, in Taiku, etc., a simple formula: number of visits (s) = number of platforms (n) x currency (m), which is very inefficient;
2、数据格式问题:不同平台的API,返回的数据格式类型也是有很大区别的,当统计数据时就会因为数据格式不统一而显得非常凌乱,处理起来相当麻烦;
2. Data format issues: API from different platforms, the type of data format returned is also very different, and when statistics are not harmonized, they are very confusing and cumbersome to process;
3、法币类型不一致:因为不同国家的发行的货币类型不一样,美国发行美元,日本发行日元,中国发行人民币,获取到的价格是以不同货币类型的价格,这里就为了便于观察需要将这些不同国家交易所的价格进行一个此时兑换人民币汇率的转换,也不是很方便。
3. The type of French currency is inconsistent: because different countries issue different types of currency, the United States dollar, Japan yen and China renminbi, the price obtained is in different currency types, and it is not convenient to observe the need for a conversion of the prices of these different national exchanges into the renminbi at this time.
所以就想着能不能找到哪一家交易平台已经把所有的平台的价格做了一个汇总,这样我只需访问这一个交易所的网站,我就能获取到所有的交易所不同币种的价格,对比分析了很多家,发现仅有几家交易所可以观察不同平台的价格:币看、sosobtc、比特儿。
So I was wondering if I could find a trading platform where the prices of all the platforms had been aggregated, so that I could access all the exchanges'websites so that I could get prices in the different currencies of all the exchanges, compare them with many others, and find that only a few exchanges can see the prices of the different platforms: currency, sosobtc, Bitelle.
1、首先是币看,这家交易所虽然提供了方便好用的API,但是收录的币种太少,只有几款主流币,很多山寨币没有收录,比如:比特股,狗狗等,所以不考虑。
First and foremost, the exchange offers easy-to-use API, but it receives too few currencies, only a few mainstream ones, many of which are unrecorded, such as bit shares, dogs, etc., and so on.
2、sosobtc的API使用起来非常不方便,只有javascript的API,而且收录的平台和币种也是参差不齐,也不考虑。
The API of Sosobtc is very difficult to use, with only the API of Javascript, and the platforms and currencies recorded are uneven and unconsidered.
3、接着是比特儿,比特儿的手机APP有一个全球行情的按钮,非常方便,如下图,而且它还帮你按照当前兑换人民币的汇率把价格换算好了,那么直接取来就能用,而且在同一网站上,数据格式也是同一规格,处理起来就相当方便了。
Three, followed by Bitelle, Bitelle's mobile phone APP has a global flow button, which is very convenient, as shown below, and it also helps you convert prices at the current RMB exchange rate, so that they can be used directly and, on the same website, the data format is the same specification, which is easily processed.
但是遇到难题了,比特儿官方并没有提供比特儿这个获取全球行情的接口,在官网上也没有这样的一个全球行情页面供我爬取,只有在手机APP上才有全球行情的按钮,无法用wireshark、burpsuite等工具抓包分析,那可不可以抓取手机的数据呢,之前没有试过抓手机的数据,首先想到的方法是:下一个360免费wifi,开启WiFi让手机连接,这样手机的流量就会经过PC的网卡,我们就可以用wireshark等工具抓取到这些数据用来分析,谁知道这些流量都经过了360wifi的防窃听处理,根本获取不到可用的数据,这个方案行不通,纠结了很久觉得这样的方案不可行,正想回到起点用各个平台API的本办法来分别获取各币种的价格,忽然灵光一闪,可不可以用fiddler来抓取手机流量呢,之前没有试过fiddler,只是听说过这么一款软件可以抓手机的数据包,怀着做实验的心态下好fiddler,至于怎么搭建抓包环境,我搜到一个教程,里面说的很详细:https://jingyan.baidu.com/article/03b2f78c7b6bb05ea237aed2.html,然后就成功抓到包了!各个币种以及不同平台的数据都整整齐齐排布好了,这种方法是可行的!!!然后用python模拟数据头header添加上cookie,post请求就能获取到数据,实验成功!!!
But the problem has come up with the following: the next 360 free wifi, the use of WiFi to connect the mobile phone, the use of PC web cards, the use of wresark and other tools to get the data for analysis, the fact that there is only a global punctuation button on the mobile phone APP, the inability to grab data using tools such as wresark, burpsuite and so on, the possibility of extracting data from mobile phones, the first idea is that the next 360 free wifi, the use of WiFi to connect the cell phone, the flow of the cell phone will go through PC web cards, the use of wresark and so on, the data can be retrieved for analysis.
获取到想要的数据了,命令行界面看起来很吃力,不方便使用,所以用pyqt5来做GUI可视化界面,成果如下(可以按照差价率排序):
Having obtained the desired data, the command line interface appeared to be exhausting and not easy to use, so pyqt5 was used as the GUI visual interface, with the following results (to be sorted according to the difference rate):
这样看起来简单明了了……
It seems to be simple and simple.
.
.
.
.
.
.
.
.
.
.
.
然而……
And yet...
(/=_=)/~ ┴┴
注册有任何问题请添加 微信:MVIP619 拉你进入群
打开微信扫一扫
添加客服
进入交流群
发表评论