-
Notifications
You must be signed in to change notification settings - Fork 0
/
getComment.py
33 lines (25 loc) · 872 Bytes
/
getComment.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
import getRawData
import pandas as pd
raw = getRawData.getRawJson('R_SO_4_32785700', '0', '20')
def getComment(raw, comments):
comment = comments
contents = raw["comments"]
for content in contents:
part = []
content.pop('beReplied')
part.append(content["user"]['nickname'])
part.append(content["content"])
part.append(content["time"])
comment.append(part)
return comment
def getAll(id,total,limit):
comment = []
for i in range(0, int(total), 100):
raw = getRawData.getRawJson(id, i.__str__(), limit)
comment = getComment(raw, comment)
return comment
def getCSV(id,total, csv_name):
comment = getAll(id, total, '100')
df = pd.DataFrame(data=comment,
columns=['user', 'content', 'time'])
df['content'].to_csv(csv_name+'.csv', encoding='utf-8')