Skip to content

Commit bb3c530

Browse files
committed
sort
1 parent 3e2d8f4 commit bb3c530

9 files changed

Lines changed: 268 additions & 208 deletions

.idea/workspace.xml

Lines changed: 172 additions & 208 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import matplotlib.pyplot as plt
2+
3+
years = [2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017]
4+
GDPs = [256, 289, 302, 356, 389, 400, 402, 436]
5+
plt.plot(years, GDPs, color='green', marker='o', linestyle='solid')
6+
plt.title('小试牛刀')
7+
plt.ylabel('gdp')
8+
plt.show()

Python基础代码/mysql.py

Whitespace-only changes.

Python基础代码/使用bs的select选取.py

Whitespace-only changes.

Python基础代码/使用代理请求网页.py

Whitespace-only changes.

Python基础代码/利用requests模块下载图片保存文件.py

Whitespace-only changes.

Python基础代码/技巧-selenium的使用.py

Whitespace-only changes.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import pymongo
2+
import pandas
3+
import matplotlib.pyplot as plt
4+
5+
client = pymongo.MongoClient('localhost')
6+
db = client["DouyuTV"]
7+
room = db["Roominfo"]
8+
data = pandas.DataFrame(list(room.find()))
9+
# del data['_id'], data['room_src'],data['vertical_src'],data['isVertical'] #去除不需要的数据
10+
data = data[['room_id', 'nickname', 'online', 'fans']] # 取得我们指定需要的数据
11+
l = list(data)
12+
print(l)
13+
print(type(l))
14+
name = data['nickname']
15+
online = data['online']
16+
# plt.plot(name,online,color='green',marker='o',linestyle='solid')
17+
# plt.title('小试牛刀')
18+
# plt.ylabel('people')
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import socket
2+
import time
3+
from pymongo import MongoClient
4+
5+
client = MongoClient('localhost')
6+
db = client["Douyu2"]
7+
col = db["Roominfo"]
8+
9+
HOST = 'http://openbarrage.douyutv.com/'
10+
PORT = 8601
11+
RID = 606118
12+
# LOGIN_INFO = "type@=loginreq/username@=rieuse" + \
13+
# "/password@=douyu/roomid@=" + str(RID) + "/"
14+
# JION_GROUP = "type@=joingroup/rid@=" + str(RID) + "/gid@=-9999" + "/"
15+
# ROOM_ID = "type@=qrl/rid@=" + str(RID) + "/"
16+
KEEP_ALIVE = "type@=keeplive/tick@=" + \
17+
str(int(time.time())) + "/vbw@=0/k@=19beba41da8ac2b4c7895a66cab81e23/"
18+
19+
20+
# s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
21+
22+
23+
def tranMsg(content):
24+
length = bytearray([len(content) + 9, 0x00, 0x00, 0x00])
25+
code = length
26+
magic = bytearray([0xb1, 0x02, 0x00, 0x00])
27+
end = bytearray([0x00])
28+
trscont = bytes(content.encode('utf-8'))
29+
return bytes(length + code + magic + trscont + end)
30+
31+
32+
def create_Conn():
33+
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
34+
s.connect((HOST, PORT))
35+
RID = 606118
36+
print("当前最热房间:", RID)
37+
LOGIN_INFO = "type@=loginreq/username@=rieuse" + \
38+
"/password@=douyu/roomid@=" + str(RID) + "/"
39+
print(LOGIN_INFO)
40+
JION_GROUP = "type@=joingroup/rid@=" + str(RID) + "/gid@=-9999" + "/"
41+
print(JION_GROUP)
42+
s.sendall(tranMsg(LOGIN_INFO))
43+
s.sendall(tranMsg(JION_GROUP))
44+
return s
45+
46+
47+
def insert_msg(sock):
48+
sendtime = 0
49+
while True:
50+
if sendtime % 20 == 0:
51+
print("----------Keep Alive---------")
52+
try:
53+
sock.sendall(tranMsg(KEEP_ALIVE))
54+
except socket.error:
55+
print("alive error")
56+
sock = create_Conn()
57+
insert_msg(sock)
58+
sendtime += 1
59+
print(sendtime)
60+
try:
61+
data = sock.recv(4000)
62+
except socket.error:
63+
print("chat error")
64+
sock = create_Conn()
65+
insert_msg(sock)
66+
time.sleep(1)
67+
68+
69+
if __name__ == '__main__':
70+
insert_msg(create_Conn())

0 commit comments

Comments
 (0)