text
stringlengths 0
18.7k
|
|---|
抽 star= commentlnfo.find_all(\"spanN")[1].get(\'"title\"))Nn,
|
训 #1.10---获取评论正文 span class=N"shortN\'Nn'",
|
commentText =
|
comment.find(\"spanN'"attrs={\"classN':N\"short\"}).text.replace(\"\NnN NAN )Nn
|
这 #1.11---将作者、打分、评论拼接成列表\n",
|
yingping = [authonrstapcommentTextj\n'",
|
训 #1.12---将每条评论到添加到 commentList 中\n",
|
commentList.append(yingping)Nn'",
|
return commentListy\n',
|
"An
|
"import csv;N\n',
|
"将评论写入到 csv 文件中\,
|
"def writeCcomment(commentListj:Nn
|
本 with open人"流浪地球.cswW'"N"wNunewline=N'Nuwencoding=N"utf-8N\") as file:\n'",
|
CSsVWriter = csv.Writer(file))Nn',
|
nn
|
nn
|
"f_name__ ==”, main_'Nn',
|
” 。 # 定义存储评论的列表ww
|
抽 commentList = []\n'",
|
csvWriter.writerows(commentList)j)Nn
|
foriin range(10):\n,
|
抽 baseUrl =
|
N'https://movie.douban.com/subject/26266893/comments?start=%d&limit=20&sort=new_score
|
&status=P\" % (\n'",
|
有 ix 20)\nv
|
" #调用获取影评的方法\n",
|
commentList = getComment(baseUrl,commentList))\n'",
|
#调用写入 csv 的方法\n",
|
writeComment(commentList);”
|
]
|
站
|
{
|
"cell_type": "code ,
|
"execution_count": 36,
|
"metadata'": 仆,
|
"outputs": [],
|
"Source'": [
|
"import csvN\n',
|
"import jieba\n'",
|
"from wordcloud import WordCcloud:\n
|
"from PILimport ImageNn',
|
"import numpyNn
|
"def readData():N\n'
|
"” # 豆办的1星到5星分别代表什么: 很差、较差、还行、推荐、力荐\n",
|
” stars = (很差\N"较差\\N还行\N" 推荐\\N"力荐\)Nnv,
|
"” ,#定义列表,存储最终的评论结果\n",
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.