大作业原话copyV●ᴥ●V
注:①由于电脑原因,爬虫并未用多线程且安装scrapy失败,全程未用啥高级操作,基本是辛苦操作hhh
注:②部分代码可能与简书作者“小黄的小憩站”类似,因为那是我本人,所以emm..
第一部分:输入你喜欢的中文作家名字,返回作家标签,主要作品及每部作品总标签数、主要标签、短评数、书评数
注:为缩短爬虫时间,最好爬完前十几本就停下吧hhh(会有提示是否继续的操作)
第二部分:作者主要作品各前20位评论者个人页面展示;
第三部分:以上罗列的第一部作品读者情况的具体展示:
①读者个人页面、地址,nickname,加入时间(有些用户未填地址)
注:每爬取10个读者信息会提醒你是否能继续,建议最好爬取20-30个,既不耗太多时间又能为②③的图表绘制提供更详实的数据
②读者出生地竖状图
③读者评论词云+词频直方图
要查看该作者其他书籍读者情况 请将源代码booknameList[0]与numsOfShortReview[0])//20中的0改为其他较小的数字。
#说明:请勿搜索一些很冷门的作者或作品
import urllib
import re
import urllib.request
headers=("User-Agent","Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/38.0.2125.122 Safari/537.36 SE 2.X MetaSr 1.0")
opener = urllib.request.build_opener()
opener.addheaders = [headers]
#将opener安装为全局
urllib.request.install_opener(opener)
search=input('输入你想搜索的作者(中文名):')
search=urllib.parse.quote(search)
print('https://book.douban.com/tag/'+str(search))
data3=urllib.request.urlopen('https://book.douban.com/tag/'+str(search)).read().decode("utf-8")
#构建对应作者作品的正则表达式
bookwebPattern='<h2 class="">\n\s\s\s\s\s\s\s\s\s\s\s\s\s\s<a href="(.*?)" title="'
bookweb=re.compile(bookwebPattern).findall(data3)
websOfBookReview=[]
numsOfShortReview=[]
booknameList=[]
flag='1'
print('该作者主要作品:')
#依次打印每部作品名称及对应标签
for i in bookweb:
data4=urllib.request.urlopen(i).read().decode("utf-8")
#构建对应作者特定作品名称的正则表达式
booknamePattern='v:itemreviewed">(.*?)<'
bookname=re.compile(booknamePattern).findall(data4)
booknameList.append(bookname)
print('书名:',bookname,i)
#构建对应作者特定作品标签的正则表达式
certainBookTagPattern='tag" href="/tag/(.*?)">'
certainBookTag=re.compile(certainBookTagPattern).findall(data4)
#构建对应作者特定作品总标签数的正则表达式
tagnumsPattern='豆瓣成员常用的标签(.*?)<'
tagnums=re.compile(tagnumsPattern).findall(data4)
print('总标签数:',str(tagnums),'主要标签:',certainBookTag)
#构建对应作者特定作品评论网页的正则表达式
readerPattern='<a\shref="(.*?)">全部(.*?)条'
reader=re.compile(readerPattern).findall(data4)
#将几部作品的读者评论网页记录在websOfBookReview列表,待呈现完作者及主要作品的主要情况后再据需统计某几部作品读者情况
websOfBookReview.append(reader[0][0])
numsOfShortReview.append(reader[0][1])
if len(booknameList)%10 and len(booknameList)>10:
flag=input('want to stop analysizing more users? press 0 to quit else press 1:')
if flag=='0':
break
print('短评网页+数量:',reader[0][0],reader[0][1],'书评数量:',reader[1][1],'\n')
for i in range(len(websOfBookReview)):
print(booknameList[i],'前20位评论者个人页面展示:')
data5=urllib.request.urlopen(websOfBookReview[i]).read().decode("utf-8")
bookname=re.compile(booknamePattern).findall(data4)
#构建对应特定读者个人主页的正则表达式
webOfCertainUserPattern='<a title=".*?"\shref="(.*?)>\s*?<img'
webOfCertainUser=re.compile(webOfCertainUserPattern).findall(data5)
print(webOfCertainUser)
numOfCountedUsers=0
addressList=[]
bookcomment=[]
num='1' #停止标识符,当觉得时间等的够久了或收集的数据足够多了就可输入0以停止爬虫
print('以下为',booknameList[0],'读者情况的具体展示,要查看该作者其他书籍读者情况',\
'请将源代码booknameList[0]与numsOfShortReview[0])//20中的0改为其他较小的数字。\n')
for i in range(int(numsOfShortReview[0])//20):#①评论绝大多数为短评,因爬虫时间有限只考虑短评。②每个评论页有20个用户
#③这里numsOfShortReview[0]指要对第一本书读者进行统计,事实上numsOfShortReview[1]也行(对第二本书读者进行统计)
if num=='0':
break
data5=urllib.request.urlopen(websOfBookReview[0]+'hot?p='+str(i)).read().decode("utf-8")
bookname=re.compile(booknamePattern).findall(data5)
#构建对应特定作品读者评论的正则表达式
commentPattern='<p class="comment-content">\s.*?\n.*?<span class="short">(.*?)<\/span>'
comment=re.compile(commentPattern).findall(data5)
bookcomment.append(comment)
#构建对应特定读者个人主页的正则表达式
webOfCertainUserPattern='<a title=".*?"\shref="(.*?)">\s*?<img '
webOfCertainUserTemp=re.compile(webOfCertainUserPattern).findall(data5)
for j in webOfCertainUserTemp:
data6=urllib.request.urlopen(j).read().decode("utf-8")
bookname=re.compile(booknamePattern).findall(data6)
#构建对应特定读者个人主页居住地及加入日期的正则表达式
InfoUserPattern='常居: <a href=".*?>(.*?)<\/a>.*?\n\n.*?class.*?>(.*?)<.*?>(.*?)<\/div>'
InfoUser=re.compile(InfoUserPattern).findall(data6)
print('读者个人页面:',j,'地址,nickname,加入时间(有些用户未填地址):',InfoUser)
if InfoUser !=[]:
addressList.append(InfoUser[0][0])
numOfCountedUsers+=1
if numOfCountedUsers%10==0:
num=input('want to stop analysizing more users? press 0 to quit else press 1:')
if num=='0':
break
print("\n第二部分--已爬取读者的常住地分布:(因时间关系部分读者未爬故未统计)")
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
import matplotlib
for item in set(addressList):
print('nums of',item,':',addressList.count(item))
# 中文和负号的正常显示
matplotlib.rcParams['font.sans-serif']=['SimHei'] # 用黑体显示中文
matplotlib.rcParams['axes.unicode_minus']=False # 正常显示负号
addressDataFrame=pd.Series(addressList)
addressDataFrame=addressDataFrame.value_counts().sort_values(ascending=False)
#当读者太多,出生地址太多时,去频率最高的前20个进行展示
if len(addressDataFrame)<20:
pass
else:
addressDataFrame=addressDataFrame[1:20]
plt.xticks(rotation=90)
plt.bar(addressDataFrame.index,addressDataFrame)
plt.show()
print('\n第三部分--对',str(booknameList[0]),'的评论词频统计:')
from wordcloud import WordCloud,ImageColorGenerator
import matplotlib.pyplot as plt
from scipy.misc import imread
import jieba
import jieba.analyse
import os, codecs
from collections import Counter
tags = jieba.analyse.extract_tags(str(bookcomment), topK=100, withWeight=False)
text =" ".join(tags)
# text = unicode(text)
#读入背景图片
bj_pic=imread('ciyun.jpg')
#生成词云(通常字体路径均设置在C:\\Windows\\Fonts\\也可自行下载)
font=r'C:\\Windows\\Fonts\\STFANGSO.ttf'#不加这一句显示口字形乱码 ""报错
wordcloud=WordCloud(mask=bj_pic,background_color='white',font_path=font,scale=3.5).generate(text)
#img_color = ImageColorGenerator(self.img)
image_colors=ImageColorGenerator(bj_pic)
#显示词云
plt.imshow(wordcloud)
plt.axis('off')
plt.show()
wordcloud.to_file('test.jpg')
#词频统计
seg_list = jieba.cut(str(bookcomment))
c = Counter()
for x in seg_list:
if len(x)>1 and x != '\r\n':
c[x] += 1
hotWordIntext=[]
hotWordNumIntext=[]
for (k,v) in c.most_common(20):
hotWordIntext.append(k)
hotWordNumIntext.append(v)
hotWordIntextDataFrame=pd.DataFrame(hotWordNumIntext,index=hotWordIntext,columns=['nums'])
#当读者太多,出生地址太多时,去频率最高的前20个进行展示
print('热点词频度统计结果(只显示前20)')
plt.xticks(rotation=90)
plt.bar(hotWordIntextDataFrame.index,hotWordIntextDataFrame.nums)
plt.show()
bookcomment=[]
hotWordIntext=[]
hotWordNumIntext=[]
addressList=[]
websOfBookReview=[] #为防止下次冗余而特地清空评论网页列表
booknameList=[]
numsOfShortReview=[]
输入你想搜索的作者(中文名):金庸
https://book.douban.com/tag/%E9%87%91%E5%BA%B8
该作者主要作品:
书名: ['天龙八部'] https://book.douban.com/subject/1255625/
总标签数: ['(共1616个)'] 主要标签: ['金庸', '武侠', '天龙八部', '小说', '武侠小说', '经典', '中国文学', '中国']
短评网页+数量: https://book.douban.com/subject/1255625/comments/ 11030 书评数量: 714
书名: ['笑傲江湖(全四册)'] https://book.douban.com/subject/1002299/
总标签数: ['(共1572个)'] 主要标签: ['金庸', '武侠', '笑傲江湖', '小说', '武侠小说', '经典', '中国', '中国文学']
短评网页+数量: https://book.douban.com/subject/1002299/comments/ 10109 书评数量: 542
书名: ['神雕侠侣'] https://book.douban.com/subject/1255624/
总标签数: ['(共1384个)'] 主要标签: ['金庸', '武侠', '神雕侠侣', '小说', '武侠小说', '经典', '爱情', '中国']
短评网页+数量: https://book.douban.com/subject/1255624/comments/ 7751 书评数量: 388
书名: ['射雕英雄传(全四册)'] https://book.douban.com/subject/1044547/
总标签数: ['(共933个)'] 主要标签: ['金庸', '武侠', '射雕英雄传', '小说', '武侠小说', '经典', '中国', '中国文学']
短评网页+数量: https://book.douban.com/subject/1044547/comments/ 4547 书评数量: 388
书名: ['鹿鼎记(全五册)'] https://book.douban.com/subject/1212893/
总标签数: ['(共828个)'] 主要标签: ['金庸', '武侠', '鹿鼎记', '小说', '武侠小说', '经典', '韦小宝', '中国']
短评网页+数量: https://book.douban.com/subject/1212893/comments/ 3540 书评数量: 268
书名: ['倚天屠龙记(共四册)'] https://book.douban.com/subject/1070851/
总标签数: ['(共795个)'] 主要标签: ['金庸', '武侠', '倚天屠龙记', '小说', '武侠小说', '经典', '中国', '中国文学']
短评网页+数量: https://book.douban.com/subject/1070851/comments/ 3887 书评数量: 212
书名: ['金庸作品集'] https://book.douban.com/subject/2218216/
总标签数: ['(共181个)'] 主要标签: ['金庸', '武侠', '经典', '武侠小说', '金庸作品集', '小说', '中国文学', '文学']
短评网页+数量: https://book.douban.com/subject/2218216/comments/ 1023 书评数量: 82
书名: ['金庸全集'] https://book.douban.com/subject/3532347/
总标签数: ['(共148个)'] 主要标签: ['金庸', '武侠', '小说', '武侠小说', '经典', '金庸全集', '三联', '中国文学']
短评网页+数量: https://book.douban.com/subject/3532347/comments/ 667 书评数量: 27
书名: ['倚天屠龙记'] https://book.douban.com/subject/1789841/
总标签数: ['(共567个)'] 主要标签: ['金庸', '武侠', '小说', '武侠小说', '倚天屠龙记', '经典', '中国', '中国文学']
短评网页+数量: https://book.douban.com/subject/1789841/comments/ 3415 书评数量: 189
书名: ['金庸江湖志'] https://book.douban.com/subject/27025043/
总标签数: ['(共27个)'] 主要标签: ['金庸', '随笔', '类别/文学评论', '作家/刘勃', '武侠', '文学', '武评', '文学杂论']
短评网页+数量: https://book.douban.com/subject/27025043/comments/ 35 书评数量: 1
书名: ['金庸师承考'] https://book.douban.com/subject/27025053/
总标签数: ['(共27个)'] 主要标签: ['金庸', '武侠', '考据', '文学', '随笔', '文学杂论', '传记', '2017']
want to stop analysizing more users? press 0 to quit else press 1:0
['天龙八部'] 前20位评论者个人页面展示:
['https://www.douban.com/people/Q598176297/"', 'https://www.douban.com/people/andy.L/"', 'https://www.douban.com/people/48569791/"', 'https://www.douban.com/people/RongFuYiTai6/"', 'https://www.douban.com/people/hovialy/"', 'https://www.douban.com/people/thinkingmind/"', 'https://www.douban.com/people/esunchien/"', 'https://www.douban.com/people/zhoukang/"', 'https://www.douban.com/people/Uroboros/"', 'https://www.douban.com/people/llll916/"', 'https://www.douban.com/people/35683587/"', 'https://www.douban.com/people/luxiaobao/"', 'https://www.douban.com/people/haha65ma/"', 'https://www.douban.com/people/Jerry-feng/"', 'https://www.douban.com/people/teenspiritkkl/"', 'https://www.douban.com/people/otaku_not_in/"', 'https://www.douban.com/people/amoyi04/"', 'https://www.douban.com/people/putengfei/"', 'https://www.douban.com/people/samantha61272/"', 'https://www.douban.com/people/luxifaer/"']
['笑傲江湖(全四册)'] 前20位评论者个人页面展示:
['https://www.douban.com/people/cxmin/"', 'https://www.douban.com/people/Uroboros/"', 'https://www.douban.com/people/DreamerWang/"', 'https://www.douban.com/people/yamamaya/"', 'https://www.douban.com/people/tzy608/"', 'https://www.douban.com/people/guo77/"', 'https://www.douban.com/people/liubinyan/"', 'https://www.douban.com/people/hexiaoqin/"', 'https://www.douban.com/people/60619603/"', 'https://www.douban.com/people/thinkingmind/"', 'https://www.douban.com/people/dancebaby/"', 'https://www.douban.com/people/floatingmeat/"', 'https://www.douban.com/people/3200262/"', 'https://www.douban.com/people/x3df16/"', 'https://www.douban.com/people/woaiyaya/"', 'https://www.douban.com/people/ashinstancy/"', 'https://www.douban.com/people/dingxu/"', 'https://www.douban.com/people/Hamlet-Luang/"', 'https://www.douban.com/people/nettoyer/"', 'https://www.douban.com/people/audreyang/"']
['神雕侠侣'] 前20位评论者个人页面展示:
['https://www.douban.com/people/baiaige/"', 'https://www.douban.com/people/Uroboros/"', 'https://www.douban.com/people/yoyoyoyoyoyoyo/"', 'https://www.douban.com/people/Jerry-feng/"', 'https://www.douban.com/people/chenmodewan/"', 'https://www.douban.com/people/bcbulang/"', 'https://www.douban.com/people/feelvoice/"', 'https://www.douban.com/people/1915877/"', 'https://www.douban.com/people/graypick/"', 'https://www.douban.com/people/41696616/"', 'https://www.douban.com/people/lililalilila/"', 'https://www.douban.com/people/huanwen/"', 'https://www.douban.com/people/yuxiaofan/"', 'https://www.douban.com/people/Dathia_/"', 'https://www.douban.com/people/1002226/"', 'https://www.douban.com/people/100593744/"', 'https://www.douban.com/people/giverny/"', 'https://www.douban.com/people/river712/"', 'https://www.douban.com/people/Azeril/"', 'https://www.douban.com/people/diaoduoxi/"']
['射雕英雄传(全四册)'] 前20位评论者个人页面展示:
['https://www.douban.com/people/angelicaljoe/"', 'https://www.douban.com/people/woqizhema/"', 'https://www.douban.com/people/36541079/"', 'https://www.douban.com/people/amsingapore/"', 'https://www.douban.com/people/huangrs555/"', 'https://www.douban.com/people/llll916/"', 'https://www.douban.com/people/131697546/"', 'https://www.douban.com/people/echobest/"', 'https://www.douban.com/people/panhan/"', 'https://www.douban.com/people/lingxiaxia/"', 'https://www.douban.com/people/houtouchong/"', 'https://www.douban.com/people/SlingXXXBlade/"', 'https://www.douban.com/people/pcissi/"', 'https://www.douban.com/people/ayida365/"', 'https://www.douban.com/people/Uroboros/"', 'https://www.douban.com/people/jfzj/"', 'https://www.douban.com/people/ztftom/"', 'https://www.douban.com/people/30574292/"', 'https://www.douban.com/people/lazycat_eva/"', 'https://www.douban.com/people/huangjingyun/"']
['鹿鼎记(全五册)'] 前20位评论者个人页面展示:
['https://www.douban.com/people/tanglu1110/"', 'https://www.douban.com/people/thinkingmind/"', 'https://www.douban.com/people/35819210/"', 'https://www.douban.com/people/bcbulang/"', 'https://www.douban.com/people/shanelean/"', 'https://www.douban.com/people/18606192/"', 'https://www.douban.com/people/4058013/"', 'https://www.douban.com/people/RongFuYiTai6/"', 'https://www.douban.com/people/tongchu/"', 'https://www.douban.com/people/Jerry-feng/"', 'https://www.douban.com/people/jokers/"', 'https://www.douban.com/people/melody1971/"', 'https://www.douban.com/people/172453309/"', 'https://www.douban.com/people/bighead/"', 'https://www.douban.com/people/jiegumu/"', 'https://www.douban.com/people/zishuiyilan/"', 'https://www.douban.com/people/szemm/"', 'https://www.douban.com/people/2922325/"', 'https://www.douban.com/people/jiajiaaixuexi/"', 'https://www.douban.com/people/CFJ/"']
['倚天屠龙记(共四册)'] 前20位评论者个人页面展示:
['https://www.douban.com/people/xyws/"', 'https://www.douban.com/people/2158612/"', 'https://www.douban.com/people/pixstones/"', 'https://www.douban.com/people/jfzj/"', 'https://www.douban.com/people/piaoliumutou/"', 'https://www.douban.com/people/51938915/"', 'https://www.douban.com/people/kianfish/"', 'https://www.douban.com/people/charlizheng/"', 'https://www.douban.com/people/moniang/"', 'https://www.douban.com/people/toamo/"', 'https://www.douban.com/people/4295926/"', 'https://www.douban.com/people/asoloman/"', 'https://www.douban.com/people/ztftom/"', 'https://www.douban.com/people/jeffersontang/"', 'https://www.douban.com/people/knoppix/"', 'https://www.douban.com/people/neverecho/"', 'https://www.douban.com/people/Uroboros/"', 'https://www.douban.com/people/kkdolphin/"', 'https://www.douban.com/people/yuxiaofan/"', 'https://www.douban.com/people/18606192/"']
['金庸作品集'] 前20位评论者个人页面展示:
['https://www.douban.com/people/yoyoyoyoyoyoyo/"', 'https://www.douban.com/people/memotown07/"', 'https://www.douban.com/people/QianMinjie/"', 'https://www.douban.com/people/46602436/"', 'https://www.douban.com/people/phoebejk/"', 'https://www.douban.com/people/carrie_j/"', 'https://www.douban.com/people/aibufen/"', 'https://www.douban.com/people/RYweiyang/"', 'https://www.douban.com/people/yobalcony/"', 'https://www.douban.com/people/2434887/"', 'https://www.douban.com/people/Rockyxx/"', 'https://www.douban.com/people/2282003/"', 'https://www.douban.com/people/tengyu/"', 'https://www.douban.com/people/queen_kw/"', 'https://www.douban.com/people/xuannov/"', 'https://www.douban.com/people/50275537/"', 'https://www.douban.com/people/JunoZ/"', 'https://www.douban.com/people/AnsonWan/"', 'https://www.douban.com/people/tttttgarden/"', 'https://www.douban.com/people/3017985/"']
['金庸全集'] 前20位评论者个人页面展示:
['https://www.douban.com/people/knoppix/"', 'https://www.douban.com/people/renshuangxia/"', 'https://www.douban.com/people/luhua/"', 'https://www.douban.com/people/35819210/"', 'https://www.douban.com/people/kevindreamfly/"', 'https://www.douban.com/people/yamamaya/"', 'https://www.douban.com/people/liveonnoevil/"', 'https://www.douban.com/people/Reuenthal/"', 'https://www.douban.com/people/luoxr/"', 'https://www.douban.com/people/abracadebraie/"', 'https://www.douban.com/people/bendao/"', 'https://www.douban.com/people/26425322/"', 'https://www.douban.com/people/mattviola/"', 'https://www.douban.com/people/luchun/"', 'https://www.douban.com/people/53072535/"', 'https://www.douban.com/people/RYweiyang/"', 'https://www.douban.com/people/youyv/"', 'https://www.douban.com/people/xiaoxinzei/"', 'https://www.douban.com/people/137573685/"', 'https://www.douban.com/people/2691728/"']
['倚天屠龙记'] 前20位评论者个人页面展示:
['https://www.douban.com/people/ilovelittlesnow/"', 'https://www.douban.com/people/joyjoy2/"', 'https://www.douban.com/people/Ixtab/"', 'https://www.douban.com/people/thinkingmind/"', 'https://www.douban.com/people/ranwei/"', 'https://www.douban.com/people/ekisyou/"', 'https://www.douban.com/people/PomBom/"', 'https://www.douban.com/people/jiegumu/"', 'https://www.douban.com/people/yimihai/"', 'https://www.douban.com/people/poltergeist/"', 'https://www.douban.com/people/1884631/"', 'https://www.douban.com/people/51549032/"', 'https://www.douban.com/people/panhan/"', 'https://www.douban.com/people/naocanqiang/"', 'https://www.douban.com/people/feelvoice/"', 'https://www.douban.com/people/56500125/"', 'https://www.douban.com/people/melody1971/"', 'https://www.douban.com/people/reaplay/"', 'https://www.douban.com/people/Q598176297/"', 'https://www.douban.com/people/Erman-Wei/"']
['金庸江湖志'] 前20位评论者个人页面展示:
['https://www.douban.com/people/39008769/"', 'https://www.douban.com/people/huanwen/"', 'https://www.douban.com/people/29007604/"', 'https://www.douban.com/people/45074177/"', 'https://www.douban.com/people/kfcai/"', 'https://www.douban.com/people/renzicai/"', 'https://www.douban.com/people/yuyanlin/"', 'https://www.douban.com/people/BenGlen/"', 'https://www.douban.com/people/jeanky/"', 'https://www.douban.com/people/kergee/"', 'https://www.douban.com/people/3195337/"', 'https://www.douban.com/people/47241007/"', 'https://www.douban.com/people/43707842/"', 'https://www.douban.com/people/33230145/"', 'https://www.douban.com/people/61452683/"', 'https://www.douban.com/people/122509122/"', 'https://www.douban.com/people/64155300/"', 'https://www.douban.com/people/evansey/"', 'https://www.douban.com/people/Natezhang/"', 'https://www.douban.com/people/148908017/"']
['金庸师承考'] 前20位评论者个人页面展示:
['https://www.douban.com/people/45074177/"', 'https://www.douban.com/people/39008769/"', 'https://www.douban.com/people/jeanky/"', 'https://www.douban.com/people/67459918/"', 'https://www.douban.com/people/46610300/"', 'https://www.douban.com/people/2843196/"', 'https://www.douban.com/people/2294702/"', 'https://www.douban.com/people/rjbfq/"', 'https://www.douban.com/people/evansey/"', 'https://www.douban.com/people/68321623/"', 'https://www.douban.com/people/47241007/"', 'https://www.douban.com/people/64155300/"', 'https://www.douban.com/people/131615477/"', 'https://www.douban.com/people/156796942/"', 'https://www.douban.com/people/lovezone/"', 'https://www.douban.com/people/71538147/"', 'https://www.douban.com/people/158258095/"', 'https://www.douban.com/people/178349453/"', 'https://www.douban.com/people/woniuzailushang/"', 'https://www.douban.com/people/162614038/"']
以下为 ['天龙八部'] 读者情况的具体展示,要查看该作者其他书籍读者情况 请将源代码booknameList[0]与numsOfShortReview[0])//20中的0改为其他较小的数字。
读者个人页面: https://www.douban.com/people/Q598176297/ 地址,nickname,加入时间(有些用户未填地址): [('广东广州', 'Q598176297 ', ' 2012-04-24加入')]
读者个人页面: https://www.douban.com/people/andy.L/ 地址,nickname,加入时间(有些用户未填地址): [('上海', 'andy.L ', ' 2008-08-03加入')]
读者个人页面: https://www.douban.com/people/48569791/ 地址,nickname,加入时间(有些用户未填地址): [('西藏山南', '48569791 ', ' 2011-01-04加入')]
读者个人页面: https://www.douban.com/people/RongFuYiTai6/ 地址,nickname,加入时间(有些用户未填地址): [('Atlanta, United States', 'RongFuYiTai6 ', ' 2009-12-09加入')]
读者个人页面: https://www.douban.com/people/hovialy/ 地址,nickname,加入时间(有些用户未填地址): [('Seattle, United States', 'hovialy ', ' 2006-11-24加入')]
读者个人页面: https://www.douban.com/people/thinkingmind/ 地址,nickname,加入时间(有些用户未填地址): [('北京', 'thinkingmind ', ' 2011-08-07加入')]
读者个人页面: https://www.douban.com/people/esunchien/ 地址,nickname,加入时间(有些用户未填地址): [('北京', 'esunchien ', ' 2007-10-14加入')]
读者个人页面: https://www.douban.com/people/zhoukang/ 地址,nickname,加入时间(有些用户未填地址): [('Roma, Italy', 'zhoukang ', ' 2006-03-08加入')]
读者个人页面: https://www.douban.com/people/Uroboros/ 地址,nickname,加入时间(有些用户未填地址): [('Dublin (Baile Átha Cliath), Ireland', 'Uroboros ', ' 2009-03-25加入')]
读者个人页面: https://www.douban.com/people/llll916/ 地址,nickname,加入时间(有些用户未填地址): [('北京', 'llll916 ', ' 2007-02-04加入')]
want to stop analysizing more users? press 0 to quit else press 1:1
读者个人页面: https://www.douban.com/people/35683587/ 地址,nickname,加入时间(有些用户未填地址): [('上海', '35683587 ', ' 2010-02-22加入')]
读者个人页面: https://www.douban.com/people/luxiaobao/ 地址,nickname,加入时间(有些用户未填地址): [('上海', 'luxiaobao ', ' 2009-11-19加入')]
读者个人页面: https://www.douban.com/people/haha65ma/ 地址,nickname,加入时间(有些用户未填地址): [('北京', 'haha65ma ', ' 2009-10-28加入')]
读者个人页面: https://www.douban.com/people/Jerry-feng/ 地址,nickname,加入时间(有些用户未填地址): [('北京', 'Jerry-feng ', ' 2011-01-17加入')]
读者个人页面: https://www.douban.com/people/teenspiritkkl/ 地址,nickname,加入时间(有些用户未填地址): [('北京', 'teenspiritkkl ', ' 2007-12-12加入')]
读者个人页面: https://www.douban.com/people/otaku_not_in/ 地址,nickname,加入时间(有些用户未填地址): [('北京', 'otaku_not_in ', ' 2010-10-07加入')]
读者个人页面: https://www.douban.com/people/amoyi04/ 地址,nickname,加入时间(有些用户未填地址): [('P'yŏngyang, North Korea', 'amoyi04 ', ' 2010-04-03加入')]
读者个人页面: https://www.douban.com/people/putengfei/ 地址,nickname,加入时间(有些用户未填地址): [('北京', 'putengfei ', ' 2008-12-03加入')]
读者个人页面: https://www.douban.com/people/samantha61272/ 地址,nickname,加入时间(有些用户未填地址): [('北京', 'samantha61272 ', ' 2008-11-17加入')]
读者个人页面: https://www.douban.com/people/luxifaer/ 地址,nickname,加入时间(有些用户未填地址): [('北京', 'luxifaer ', ' 2009-05-18加入')]
want to stop analysizing more users? press 0 to quit else press 1:1
读者个人页面: https://www.douban.com/people/jeffersontang/ 地址,nickname,加入时间(有些用户未填地址): [('上海', 'jeffersontang ', ' 2011-05-24加入')]
读者个人页面: https://www.douban.com/people/sungdebbie/ 地址,nickname,加入时间(有些用户未填地址): [('广东广州', 'sungdebbie ', ' 2007-05-29加入')]
读者个人页面: https://www.douban.com/people/59291955/ 地址,nickname,加入时间(有些用户未填地址): [('北京', '59291955 ', ' 2012-03-08加入')]
读者个人页面: https://www.douban.com/people/jinduoduo/ 地址,nickname,加入时间(有些用户未填地址): [('湖北神农架林区', 'jinduoduo ', ' 2009-04-09加入')]
读者个人页面: https://www.douban.com/people/DeadWalker/ 地址,nickname,加入时间(有些用户未填地址): [('北京', 'DeadWalker ', ' 2008-01-24加入')]
读者个人页面: https://www.douban.com/people/naocanqiang/ 地址,nickname,加入时间(有些用户未填地址): [('London, United Kingdom', 'naocanqiang ', ' 2006-03-18加入')]
读者个人页面: https://www.douban.com/people/tongchu/ 地址,nickname,加入时间(有些用户未填地址): [('北京', 'tongchu ', ' 2005-08-22加入')]
读者个人页面: https://www.douban.com/people/sophielikeit/ 地址,nickname,加入时间(有些用户未填地址): []
读者个人页面: https://www.douban.com/people/suev/ 地址,nickname,加入时间(有些用户未填地址): [('Ciudad de Panamá, Panama', 'suev ', ' 2009-05-12加入')]
读者个人页面: https://www.douban.com/people/oranjeruud/ 地址,nickname,加入时间(有些用户未填地址): [('上海', 'oranjeruud ', ' 2008-10-05加入')]
读者个人页面: https://www.douban.com/people/sephiroth_fool/ 地址,nickname,加入时间(有些用户未填地址): [('上海', 'sephiroth_fool ', ' 2007-10-28加入')]
want to stop analysizing more users? press 0 to quit else press 1:0
第二部分--已爬取读者的常住地分布:(因时间关系部分读者未爬故未统计)
nums of 西藏山南 : 1
nums of Ciudad de Panamá, Panama : 1
nums of 湖北神农架林区 : 1
nums of 北京 : 13
nums of Seattle, United States : 1
nums of London, United Kingdom : 1
nums of Dublin (Baile Átha Cliath), Ireland : 1
nums of 上海 : 6
nums of Roma, Italy : 1
nums of 广东广州 : 2
nums of P'yŏngyang, North Korea : 1
nums of Atlanta, United States: 1
小黄只踩了一部分人样,有时间的话您可以贴下代码尽情采样玩玩哈,但要注意url换页时page的规律性变化
第三部分--对 ['天龙八部'] 评论的‘热点词频’统计:
C:\Users\lenovo\Anaconda3\lib\site-packages\ipykernel_launcher.py:135: DeprecationWarning: `imread` is deprecated!
`imread` is deprecated in SciPy 1.0.0, and will be removed in 1.2.0.
Use ``imageio.imread`` instead.
本来想变成胡歌的样子,但发现老胡图像变糊了,就改成很common的爱心状hhh
热点词频度统计结果(只显示前20)
效果真差。。。还是去掉不少虚词的。。。
可见词云统计还是比热点词频统计(其实也运用某种手段去除了常见的虚词)准很多的嘿嘿嘿
网友评论