用Python分析Telegram群聊,把握币圈热点

        在加密货币和金融交易日益火热的今天,Telegram(TG)群聊已成为交易者们分享信息、讨论策略和捕捉市场脉搏的核心场所。这些群聊不仅是用户交流的平台,更是交易热点的实时风向标,蕴含着从价格波动到项目动态的宝贵线索。通过分析TG群聊中的讨论模式、关键词频次以及用户互动,我们可以快速识别哪些资产或事件正在成为市场关注的焦点,从而抓住交易机会。本文将深入探讨如何利用TG群聊挖掘交易热点,并提供实用方法与工具,助力读者在瞬息万变的市场中抢占先机。

1.数据源准备

本文选取了当前加密货币交易所中,用户群体较大的交易所的TG中文群聊作为数据来源。具体的交易所名单如下:Binance、OKX、Bitget、Gate、Huobi、Coinbase、Kraken、Kucoin、MEXC、Bybit。

具体TG群聊链接自行搜索,为了用户安全考虑,请仔细甄别是否是官方群聊!

以Binance为例,介绍一下如何导出数据。

在群聊界面右上角找到“导出数据”,文本分析不需要勾选任何(默认导出文本,勾选是附加的),格式选择JSON,时间选择想要分析的时间段。大小限制任意,可以选择拉满。

2.代码

以下代码是以某个群聊为数据源,生成词云图的。停用词库将放在最后。

import json
import jieba
from wordcloud import WordCloud
import matplotlib.pyplot as plt

# 使用你的文件路径
file_path = r'C:\Users\result.json'

# 读取JSON文件
with open(file_path, 'r', encoding='utf-8') as file:
    data = json.load(file)

# 提取非空文本消息
messages = []
for msg in data.get('messages', []):
    if 'text' in msg and isinstance(msg['text'], str) and msg['text'].strip():
        messages.append(msg['text'])

# 合并消息并分词
text = ' '.join(messages)
words = jieba.cut(text)
text = ' '.join(words)

# 读取停用词文件
stopwords_path = 'C:\Users\停用词库.txt'
with open(stopwords_path, 'r', encoding='utf-8') as f:
    stopwords = set(f.read().splitlines())

# 生成词云(使用文件中的停用词)
font_path = 'C:\\Windows\\Fonts\\simhei.ttf'
wordcloud = WordCloud(
    font_path=font_path,
    width=800,
    height=400,
    background_color='white',
    stopwords=stopwords  # 使用从文件读取的停用词
).generate(text)

# 显示并保存
plt.figure(figsize=(10, 5))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis('off')
plt.show()
wordcloud.to_file('wordcloud_with_stopwords.png')

# 补充导出文件的路径
output_path = r'C:\Users\wordcloud_output.jpg' # 修改为你想要的路径
wordcloud.to_file(output_path)
print(f"词云已保存到: {output_path}")

3.多个群聊json输出为一张图片

注意,需要将多个json文件存放在一个文件夹中,导入的路径是文件夹的路径,而不是文件。

import json
import jieba
from wordcloud import WordCloud
import matplotlib.pyplot as plt
import os

# 定义文件路径列表(假设你的 JSON 文件都在同一个目录下)
folder_path = r'C:\Users\json'  # 修改为你的 JSON 文件所在文件夹路径,是文件夹,不是文件
json_files = [f for f in os.listdir(folder_path) if f.endswith('.json')]  # 获取所有 .json 文件

# 提取所有消息
all_messages = []
for json_file in json_files:
    file_path = os.path.join(folder_path, json_file)  # 拼接完整路径
    with open(file_path, 'r', encoding='utf-8') as file:
        data = json.load(file)
        # 提取非空文本消息
        for msg in data.get('messages', []):
            if 'text' in msg and isinstance(msg['text'], str) and msg['text'].strip():
                all_messages.append(msg['text'])

# 合并消息并分词
text = ' '.join(all_messages)
words = jieba.cut(text)
text = ' '.join(words)

# 读取停用词文件
stopwords_path = r'C:\Users\停用词库.txt'  # 修改为你的停用词文件路径
with open(stopwords_path, 'r', encoding='utf-8') as f:
    stopwords = set(f.read().splitlines())

# 生成词云
font_path = r'C:\Windows\Fonts\simhei.ttf'  # 中文字体路径
wordcloud = WordCloud(
    font_path=font_path,
    width=800,
    height=400,
    background_color='white',
    stopwords=stopwords  # 使用停用词
).generate(text)

# 显示词云
plt.figure(figsize=(10, 5))
plt.imshow(wordcloud, interpolation='bilinear')
plt.axis('off')
plt.show()

# 补充导出文件的路径
output_path = r'C:\Users\wordcloud_output.jpg' # 修改为你想要的路径
wordcloud.to_file(output_path)
print(f"词云已保存到: {output_path}")

4.停用词库

本文在常见的停用词库的基础上补充了部分币圈相关的通用词,用户可以直接复制到TXT文本中,并自行补充。

$
0
1
2
3
4
5
6
7
8
9
?
_
“
”
、
。
《
》
一
一些
一何
一切
一则
一方面
一旦
一来
一样
一般
一转眼
万一
上
上下
下
不
不仅
不但
不光
不单
不只
不外乎
不如
不妨
不尽
不尽然
不得
不怕
不惟
不成
不拘
不料
不是
不比
不然
不特
不独
不管
不至于
不若
不论
不过
不问
与
与其
与其说
与否
与此同时
且
且不说
且说
两者
个
个别
临
为
为了
为什么
为何
为止
为此
为着
乃
乃至
乃至于
么
之
之一
之所以
之类
乌乎
乎
乘
也
也好
也罢
了
二来
于
于是
于是乎
云云
云尔
些
亦
人
人们
人家
什么
什么样
今
介于
仍
仍旧
从
从此
从而
他
他人
他们
以
以上
以为
以便
以免
以及
以故
以期
以来
以至
以至于
以致
们
任
任何
任凭
似的
但
但凡
但是
何
何以
何况
何处
何时
余外
作为
你
你们
使
使得
例如
依
依据
依照
便于
俺
俺们
倘
倘使
倘或
倘然
倘若
借
假使
假如
假若
傥然
像
儿
先不先
光是
全体
全部
兮
关于
其
其一
其中
其二
其他
其余
其它
其次
具体地说
具体说来
兼之
内
再
再其次
再则
再有
再者
再者说
再说
冒
冲
况且
几
几时
凡
凡是
凭
凭借
出于
出来
分别
则
则甚
别
别人
别处
别是
别的
别管
别说
到
前后
前此
前者
加之
加以
即
即令
即使
即便
即如
即或
即若
却
去
又
又及
及
及其
及至
反之
反而
反过来
反过来说
受到
另
另一方面
另外
另悉
只
只当
只怕
只是
只有
只消
只要
只限
叫
叮咚
可
可以
可是
可见
各
各个
各位
各种
各自
同
同时
后
后者
向
向使
向着
吓
吗
否则
吧
吧哒
吱
呀
呃
呕
呗
呜
呜呼
呢
呵
呵呵
呸
呼哧
咋
和
咚
咦
咧
咱
咱们
咳
哇
哈
哈哈
哉
哎
哎呀
哎哟
哗
哟
哦
哩
哪
哪个
哪些
哪儿
哪天
哪年
哪怕
哪样
哪边
哪里
哼
哼唷
唉
唯有
啊
啐
啥
啦
啪达
啷当
喂
喏
喔唷
喽
嗡
嗡嗡
嗬
嗯
嗳
嘎
嘎登
嘘
嘛
嘻
嘿
嘿嘿
因
因为
因了
因此
因着
因而
固然
在
在下
在于
地
基于
处在
多
多么
多少
大
大家
她
她们
好
如
如上
如上所述
如下
如何
如其
如同
如是
如果
如此
如若
始而
孰料
孰知
宁
宁可
宁愿
宁肯
它
它们
对
对于
对待
对方
对比
将
小
尔
尔后
尔尔
尚且
就
就是
就是了
就是说
就算
就要
尽
尽管
尽管如此
岂但
己
已
已矣
巴
巴巴
并
并且
并非
庶乎
庶几
开外
开始
归
归齐
当
当地
当然
当着
彼
彼时
彼此
往
待
很
得
得了
怎
怎么
怎么办
怎么样
怎奈
怎样
总之
总的来看
总的来说
总的说来
总而言之
恰恰相反
您
惟其
慢说
我
我们
或
或则
或是
或曰
或者
截至
所
所以
所在
所幸
所有
才
才能
打
打从
把
抑或
拿
按
按照
换句话说
换言之
据
据此
接着
故
故此
故而
旁人
无
无宁
无论
既
既往
既是
既然
时候
是
是以
是的
曾
替
替代
最
有
有些
有关
有及
有时
有的
望
朝
朝着
本
本人
本地
本着
本身
来
来着
来自
来说
极了
果然
果真
某
某个
某些
某某
根据
欤
正值
正如
正巧
正是
此
此地
此处
此外
此时
此次
此间
毋宁
每
每当
比
比及
比如
比方
没奈何
沿
沿着
漫说
焉
然则
然后
然而
照
照着
犹且
犹自
甚且
甚么
甚或
甚而
甚至
甚至于
用
用来
由
由于
由是
由此
由此可见
的
的确
的话
直到
相对而言
省得
看
眨眼
着
着呢
矣
矣乎
矣哉
离
竟而
第
等
等到
等等
简言之
管
类如
紧接着
纵
纵令
纵使
纵然
经
经过
结果
给
继之
继后
继而
综上所述
罢了
者
而
而且
而况
而后
而外
而已
而是
而言
能
能否
腾
自
自个儿
自从
自各儿
自后
自家
自己
自打
自身
至
至于
至今
至若
致
般的
若
若夫
若是
若果 
若非
莫不然
莫如
莫若
虽
虽则
虽然
虽说
被
要
要不
要不是
要不然
要么
要是
譬喻
譬如
让
许多
论
设使
设或
设若
诚如
诚然
该
说来
诸
诸位
诸如
谁
谁人
谁料
谁知
贼死
赖以
赶
起
起见
趁
趁着
越是
距
跟
较
较之
边
过
还
还是
还有
还要
这
这一来
这个
这么
这么些
这么样
这么点儿
这些
这会儿
这儿
这就是说
这时
这样
这次
这般
这边
这里
进而
连
连同
逐步
通过
遵循
遵照
那
那个
那么
那么些
那么样
那些
那会儿
那儿
那时
那样
那般
那边
那里
都
鄙人
鉴于
针对
阿
除
除了
除外
除开
除此之外
除非
随
随后
随时
随着
难道说
非但
非徒
非特
非独
靠
顺
顺着
首先
!
,
:
;
?

'd
'll
'm
're
's
't
've
ZT
ZZ
a
a's
able
about
above
abst
accordance
according
accordingly
across
act
actually
added
adj
adopted
affected
affecting
affects
after
afterwards
again
against
ah
ain't
all
allow
allows
almost
alone
along
already
also
although
always
am
among
amongst
an
and
announce
another
any
anybody
anyhow
anymore
anyone
anything
anyway
anyways
anywhere
apart
apparently
appear
appreciate
appropriate
approximately
are
area
areas
aren
aren't
arent
arise
around
as
aside
ask
asked
asking
asks
associated
at
auth
available
away
awfully
b
back
backed
backing
backs
be
became
because
become
becomes
becoming
been
before
beforehand
began
begin
beginning
beginnings
begins
behind
being
beings
believe
below
beside
besides
best
better
between
beyond
big
biol
both
brief
briefly
but
by
c
c'mon
c's
ca
came
can
can't
cannot
cant
case
cases
cause
causes
certain
certainly
changes
clear
clearly
co
com
come
comes
concerning
consequently
consider
considering
contain
containing
contains
corresponding
could
couldn't
couldnt
course
currently
d
date
definitely
describe
described
despite
did
didn't
differ
different
differently
discuss
do
does
doesn't
doing
don't
done
down
downed
downing
downs
downwards
due
during
e
each
early
ed
edu
effect
eg
eight
eighty
either
else
elsewhere
end
ended
ending
ends
enough
entirely
especially
et
et-al
etc
even
evenly
ever
every
everybody
everyone
everything
everywhere
ex
exactly
example
except
f
face
faces
fact
facts
far
felt
few
ff
fifth
find
finds
first
five
fix
followed
following
follows
for
former
formerly
forth
found
four
from
full
fully
further
furthered
furthering
furthermore
furthers
g
gave
general
generally
get
gets
getting
give
given
gives
giving
go
goes
going
gone
good
goods
got
gotten
great
greater
greatest
greetings
group
grouped
grouping
groups
h
had
hadn't
happens
hardly
has
hasn't
have
haven't
having
he
he's
hed
hello
help
hence
her
here
here's
hereafter
hereby
herein
heres
hereupon
hers
herself
hes
hi
hid
high
higher
highest
him
himself
his
hither
home
hopefully
how
howbeit
however
hundred
i
i'd
i'll
i'm
i've
id
ie
if
ignored
im
immediate
immediately
importance
important
in
inasmuch
inc
include
indeed
index
indicate
indicated
indicates
information
inner
insofar
instead
interest
interested
interesting
interests
into
invention
inward
is
isn't
it
it'd
it'll
it's
itd
its
itself
j
just
k
keep
keeps
kept
keys
kg
kind
km
knew
know
known
knows
l
large
largely
last
lately
later
latest
latter
latterly
least
less
lest
let
let's
lets
like
liked
likely
line
little
long
longer
longest
look
looking
looks
ltd
m
made
mainly
make
makes
making
man
many
may
maybe
me
mean
means
meantime
meanwhile
member
members
men
merely
mg
might
million
miss
ml
more
moreover
most
mostly
mr
mrs
much
mug
must
my
myself
n
n't
na
name
namely
nay
nd
near
nearly
necessarily
necessary
need
needed
needing
needs
neither
never
nevertheless
new
newer
newest
next
nine
ninety
no
nobody
non
none
nonetheless
noone
nor
normally
nos
not
noted
nothing
novel
now
nowhere
number
numbers
o
obtain
obtained
obviously
of
off
often
oh
ok
okay
old
older
oldest
omitted
on
once
one
ones
only
onto
open
opened
opening
opens
or
ord
order
ordered
ordering
orders
other
others
otherwise
ought
our
ours
ourselves
out
outside
over
overall
owing
own
p
page
pages
part
parted
particular
particularly
parting
parts
past
per
perhaps
place
placed
places
please
plus
point
pointed
pointing
points
poorly
possible
possibly
potentially
pp
predominantly
present
presented
presenting
presents
presumably
previously
primarily
probably
problem
problems
promptly
proud
provides
put
puts
q
que
quickly
quite
qv
r
ran
rather
rd
re
readily
really
reasonably
recent
recently
ref
refs
regarding
regardless
regards
related
relatively
research
respectively
resulted
resulting
results
right
room
rooms
run
s
said
same
saw
say
saying
says
sec
second
secondly
seconds
section
see
seeing
seem
seemed
seeming
seems
seen
sees
self
selves
sensible
sent
serious
seriously
seven
several
shall
she
she'll
shed
shes
should
shouldn't
show
showed
showing
shown
showns
shows
side
sides
significant
significantly
similar
similarly
since
six
slightly
small
smaller
smallest
so
some
somebody
somehow
someone
somethan
something
sometime
sometimes
somewhat
somewhere
soon
sorry
specifically
specified
specify
specifying
state
states
still
stop
strongly
sub
substantially
successfully
such
sufficiently
suggest
sup
sure
t
t's
take
taken
taking
tell
tends
th
than
thank
thanks
thanx
that
that'll
that's
that've
thats
the
their
theirs
them
themselves
then
thence
there
there'll
there's
there've
thereafter
thereby
thered
therefore
therein
thereof
therere
theres
thereto
thereupon
these
they
they'd
they'll
they're
they've
theyd
theyre
thing
things
think
thinks
third
this
thorough
thoroughly
those
thou
though
thoughh
thought
thoughts
thousand
three
throug
through
throughout
thru
thus
til
tip
to
today
together
too
took
toward
towards
tried
tries
truly
try
trying
ts
turn
turned
turning
turns
twice
two
u
un
under
unfortunately
unless
unlike
unlikely
until
unto
up
upon
ups
us
use
used
useful
usefully
usefulness
uses
using
usually
uucp
v
value
various
very
via
viz
vol
vols
vs
w
want
wanted
wanting
wants
was
wasn't
way
ways
we
we'd
we'll
we're
we've
wed
welcome
well
wells
went
were
weren't
what
what'll
what's
whatever
whats
when
whence
whenever
where
where's
whereafter
whereas
whereby
wherein
wheres
whereupon
wherever
whether
which
while
whim
whither
who
who'll
who's
whod
whoever
whole
whom
whomever
whos
whose
why
widely
will
willing
wish
with
within
without
won't
wonder
words
work
worked
working
works
world
would
wouldn't
www
x
y
year
years
yes
yet
you
you'd
you'll
you're
you've
youd
young
younger
youngest
your
youre
yours
yourself
yourselves
z
zero
zt
zz
!
""""
#
$
%
&
'
(
)
*
+
","
-
.
/
:
;
<
=
>
?
@
[
\
]
^
_
`
{
|
}
~
老板
token
代币
wallet
钱包
sol
buy
池子
sell
交易
tokens
create
tax
没有
一个
fee
liqudity
币
问题
会
transaction
dm
私信
check
地址
wallets
现在
创建
私聊
一下
需要
买
卖
time
流动性
看看
说
没
知道
芝麻
已经
客服
今天
可能
玩
牛逼
不能
昨天
是不是
哈哈哈
gate
btc
合约
赚
跌
亏
不会
管理
涨
平台
真的
兄弟
项目
反正
不行
价额
现货
点
交易所
价格
应该
做
想
感觉
牛逼
钱
肯定
活动
比特
直接
一直
很多
搞

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值