<html> <p>前几天闲的没事,去sosobtc的聊天室看了看,我发现那些人一天到晚乐此不疲的发些没用的消息。不是说哪个涨了多少跌了多少,就是问某某还能不能进,某某该不该卖了,买什么赚了多少倍,骂李笑来大骗子种种。。基本上可以看出韭菜们的贪婪恐惧和无知,和各种股票群里的对话差不多。</p> <p><br></p> <p>我突发奇想,想分析下那些虚拟币交易的韭菜们到底一天到晚再聊些什么。于是写了个程序抓取聊天室的聊天记录,然后保存到mysql,然后用Python做了下词云分析。</p> <p>下面是词云的效果:</p> <p><img src="http://ww1.sinaimg.cn/large/694a5846gy1fip5lctjrcj211y0iogr4.jpg" width="1366" height="672"/></p> <p><br></p> <p><img src="http://ww1.sinaimg.cn/large/694a5846gy1fip5leznsnj210z0g5n2k.jpg" width="1331" height="581"/></p> <p><br></p> <p>应该是当天蚂蚁大涨,所以频率比较高,可以看出韭菜们对消息和市场的反应。。。</p> <p>准备工作:</p> <p>首先准备好几个准备抓取得聊天室的地址,我准备的几个地址如下:</p> <p>http://io.sosobtc.com/?chnl=okcoin&theme=light&nested=true&app=true</p> <p>https://io.sosobtc.com/?chnl=yunbi&theme=light&nested=false&app=true</p> <p>https://io.sosobtc.com/?chnl=biter&theme=light&nested=true&app=true</p> <p>https://io.sosobtc.com/?chnl=jubi&theme=light&nested=true&app=true</p> <p>可以很清楚的看到chnl就是不同的交易所,sosobtc支持很多个交易所,感兴趣的可以自己改参数试试</p> <p>由于sosobtc的聊天室是基于websocket的,所以只需要在接收信息的地方拦截消息然后发送到本地后端保存就行了</p> <p>这里我们使用Fiddle代理http://io.sosobtc.com/public/javascripts/app.js 这个js文件</p> <p>然后找到</p> <p><code>client.on('data', function onReply(data) {</code></p> <p><code>receive(data);</code></p> <p><code>});</code></p> <p><br></p> <p>可以看到这里调用receive方法来处理数据,于是在receive里面动动手脚就行啦。</p> <p><img src="http://ww1.sinaimg.cn/large/694a5846gy1fip5y6jmfbj20u30ekmza.jpg" width="1083" height="524"/></p> <p>可以看到我这里每次就是到消息就发送一个POST到本地http://localhost/msg,这样抓取数据就写好了</p> <p>localhost里面的代码就很简单了,保存post到mysql,最后是Python的词云分析。</p> <p>这一步也很简单,才几行代码,哈哈哈。。。</p> <p><br></p> <p><img src="http://ww1.sinaimg.cn/large/694a5846gy1fip5y6ztxbj20uv0ar0tm.jpg" width="1111" height="387"/></p> <p>这里需要注意如果你的文本是中文需要引入支持中文的字体,我这里引入的微软自带的字体</p> <p>就酱吧,有兴趣的可以研究研究,PY可以干很多好玩的事。</p> <p>PS:</p> <p>这里是我搜集的2w多条数据,可以下载自己跑的试试</p> <p>https://www.dropbox.com/s/gebl89uopm0103l/msg2.txt?dl=0</p> <p><br></p> <p><br></p> </html>
author | zhengkai |
---|---|
permlink | python |
category | cn |
json_metadata | {"tags":["cn","python","code","cn-writing","fun"],"image":["http://ww1.sinaimg.cn/large/694a5846gy1fip5lctjrcj211y0iogr4.jpg","http://ww1.sinaimg.cn/large/694a5846gy1fip5leznsnj210z0g5n2k.jpg","http://ww1.sinaimg.cn/large/694a5846gy1fip5y6jmfbj20u30ekmza.jpg","http://ww1.sinaimg.cn/large/694a5846gy1fip5y6ztxbj20uv0ar0tm.jpg"],"links":["http://io.sosobtc.com/?chnl=okcoin&theme=light&nested=true&app=true","https://io.sosobtc.com/?chnl=yunbi&theme=light&nested=false&app=true","https://io.sosobtc.com/?chnl=biter&theme=light&nested=true&app=true","https://io.sosobtc.com/?chnl=jubi&theme=light&nested=true&app=true","http://io.sosobtc.com/public/javascripts/app.js","http://localhost/msg,这样抓取数据就写好了","https://www.dropbox.com/s/gebl89uopm0103l/msg2.txt?dl=0"],"app":"steemit/0.1","format":"html"} |
created | 2017-08-19 09:24:12 |
last_update | 2017-08-20 08:20:27 |
depth | 0 |
children | 2 |
last_payout | 2017-08-26 09:24:12 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 5.195 HBD |
curator_payout_value | 1.240 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 1,954 |
author_reputation | -24,976,149,703 |
root_title | 用Python分析虚拟币聊天室韭菜心理 |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,248,062 |
net_rshares | 1,791,273,339,314 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
fundurian | 0 | 30,269,187,597 | 25% | ||
myfirst | 0 | 47,939,730,379 | 100% | ||
elfkitchen | 0 | 65,865,119,548 | 100% | ||
scorpion130380 | 0 | 53,960,444 | 100% | ||
tumutanzi | 0 | 1,553,019,256,467 | 11% | ||
birds90 | 0 | 83,502,453,510 | 100% | ||
nrg | 0 | 324,600,300 | 1.11% | ||
tumuta | 0 | 8,218,426,095 | 100% | ||
motomania | 0 | 110,699,728 | 100% | ||
bogdanvagner | 0 | 552,108,286 | 100% | ||
ashicarin | 0 | 597,836,800 | 100% | ||
redtea | 0 | 819,960,160 | 100% |
Hi. I am a volunteer bot for @resteembot that upvoted you. Your post was chosen at random, as part of the advertisment campaign for @resteembot. @resteembot is meant to help minnows get noticed by re-steeming their posts ----- To use the bot, one must follow it for at least 3 hours, and then make a transaction where the memo is the url of the post. If you want to learn more - [read the introduction post of @resteembot](https://steemit.com/resteembot/@resteembot/how-to-use-resteembot). If you want help spread the word - [read the advertisment program post](https://steemit.com/resteembot/@resteembot/how-to-help-resteem-bot-spread-the-word). ----- Steem ON!
author | motomania |
---|---|
permlink | re-zhengkai-python-20170819t092606814z |
category | cn |
json_metadata | "" |
created | 2017-08-19 09:26:03 |
last_update | 2017-08-19 09:26:03 |
depth | 1 |
children | 0 |
last_payout | 2017-08-26 09:26:03 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 662 |
author_reputation | -56,301,550,001 |
root_title | 用Python分析虚拟币聊天室韭菜心理 |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,248,172 |
net_rshares | 0 |
这个好玩,有意思。数据会说话。
author | tumutanzi |
---|---|
permlink | re-zhengkai-python-20170819t232839170z |
category | cn |
json_metadata | {"tags":["cn"],"app":"steemit/0.1"} |
created | 2017-08-19 23:28:39 |
last_update | 2017-08-19 23:28:39 |
depth | 1 |
children | 0 |
last_payout | 2017-08-26 23:28:39 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 HBD |
curator_payout_value | 0.000 HBD |
pending_payout_value | 0.000 HBD |
promoted | 0.000 HBD |
body_length | 15 |
author_reputation | 193,777,509,634,731 |
root_title | 用Python分析虚拟币聊天室韭菜心理 |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 HBD |
percent_hbd | 10,000 |
post_id | 12,302,868 |
net_rshares | 0 |