数据运营新媒体运营

使用WebScraper和BlueMC对微博进行数据分析(上)

2019-09-30  本文已影响0人  三少爷的见

千里之行,始于足下,今天是第9/1000步。

“双微一抖”基本算是目前新媒体矩阵的标准配置,所以我们在做竞品调研或行业分析时,免不了要去分析一下对方的微博账号。

一、常规分析

对于微博,我们首先会对它进行一个常规分析,主要包括:

1、粉丝数、微博数。

2、关注对方主要发哪方面的内容,一般来说做的好的微博都会有自己固定的话题,可以把这些话题梳理出来。接下来就是分析内容的类型,转发占多少,原创内容占多少。

3、第二个就是微博的形式,看是以图文为主,还是视频为主。

4、看每天发文的频次,大致的时间点。

5、观察是否建立了微博粉丝群,是否开通了微博问答(V+付费问答)等功能。医疗行业的还可以看他是否开通了爱问诊室。

二、数据分析

数据分析又包括两块:粉丝分析和博文分析。

1、粉丝分析

这个可以借助工具BlueMC来进行,我们将在下篇文章重点介绍。

2、博文分析

主要包括微博的阅读数、转(发)评(论)(点)赞数,因为阅读数看不到,我们可以通过转评赞数来衡量。另外,还可以利用NLPIR工具对微博内容进行定量的词频和情感分析。但是在这之前,我们首先得利用爬虫把所有微博内容爬取下来,根据之前的文章介绍,可以使用WebScraper来实现这个目的。

使用西瓜助手和WebScraper免费获取公众号历史文章

网页数据抓取工具,webscraper 最简单的数据抓取教程,人人都用得上

本文不再介绍WebScraper的基础用法,如果有问题大家可以参考上面两篇文章。我将重点分析一下抓取微博的一些注意事项。

1)页面加载

微博的数据加载逻辑稍微有点复杂,首先每个页面默认只显示一部分,需要加载数次后才能显示完整,然后才是分页加载第2、3...n页。

因此,我们首先需要建立一个Type为“Element scroll down”的元素,然后在它下面添加时间、内容、转发数、评论数和点赞数。

Delay记得设置得长一点,我这里是3000ms Selector graph

2)分页

因为涉及到分页,所以我们需要在“Start URL”中利用正则表达式来获取多页,但是我们注意到微博第一页的URL和后面页的URL不一样,导致我们无法一次性获取所有页数据,因此采取一个变通的方法,单独为第一页创建一个sitemap,然后为第2-n页再创建一个sitemap,抓取两次。

以@人民日报微博为例,第一页URL:

    https://weibo.com/p/1002062803301701/home?profile_ftype=1&is_all=1#_0

第二页URL:

    https://weibo.com/p/1002062803301701/home?is_search=0&visible=0&is_all=1&is_tag=0&profile_ftype=1&page=2#feedtop

对应的sitemap里的“Start URL”(只抓取2-10页)是:

https://weibo.com/p/1002062803301701/home?is_search=0&visible=0&is_all=1&is_tag=0&profile_ftype=1&page=[2-10]#feedtop

至此,我们就能顺利把微博的数据抓取下来。下面分别是第一页和第2-10页对应的sitemap,有需要的可以直接导入,FYI。

{"_id":"peopledaily","startUrl":["https://weibo.com/p/1002062803301701/home?profile_ftype=1&is_all=1#_0"],"selectors":[{"id":"weibo","type":"SelectorElementScroll","selector":"div.WB_cardwrap.WB_feed_vipcover:nth-of-type(n+3)","parentSelectors":["_root"],"multiple":true,"delay":"3000"},{"id":"DATE","type":"SelectorText","selector":"div.WB_detail:nth-of-type(3) > div.WB_from a.S_txt2:nth-of-type(1)","parentSelectors":["weibo"],"multiple":false,"regex":"","delay":0},{"id":"CONTENT","type":"SelectorText","selector":"div.WB_feed_detail:nth-of-type(1) div.WB_text.W_f14","parentSelectors":["weibo"],"multiple":false,"regex":"","delay":0},{"id":"TRANS","type":"SelectorText","selector":"div.WB_feed_handle:nth-of-type(2) li:nth-of-type(2) em:nth-of-type(2)","parentSelectors":["weibo"],"multiple":false,"regex":"","delay":0},{"id":"comment","type":"SelectorText","selector":"div.WB_feed_handle:nth-of-type(2) li:nth-of-type(3) em:nth-of-type(2)","parentSelectors":["weibo"],"multiple":false,"regex":"","delay":0},{"id":"rank","type":"SelectorText","selector":"div.WB_feed_handle:nth-of-type(2) li:nth-of-type(4) em:nth-of-type(2)","parentSelectors":["weibo"],"multiple":false,"regex":"","delay":0}]}

{"_id":"peopledaily2-n","startUrl":["https://weibo.com/p/1002062803301701/home?is_search=0&visible=0&is_all=1&is_tag=0&profile_ftype=1&page=[2-10]#feedtop"],"selectors":[{"id":"weibo","type":"SelectorElementScroll","selector":"div.WB_cardwrap.WB_feed_vipcover:nth-of-type(n+2)","parentSelectors":["_root"],"multiple":true,"delay":"3000"},{"id":"DATE","type":"SelectorText","selector":"div.WB_detail:nth-of-type(3) > div.WB_from a.S_txt2:nth-of-type(1)","parentSelectors":["weibo"],"multiple":false,"regex":"","delay":0},{"id":"CONTENT","type":"SelectorText","selector":"div.WB_feed_detail:nth-of-type(1) div.WB_text.W_f14","parentSelectors":["weibo"],"multiple":false,"regex":"","delay":0},{"id":"TRANS","type":"SelectorText","selector":"div.WB_feed_handle:nth-of-type(2) li:nth-of-type(2) em:nth-of-type(2)","parentSelectors":["weibo"],"multiple":false,"regex":"","delay":0},{"id":"comment","type":"SelectorText","selector":"div.WB_feed_handle:nth-of-type(2) li:nth-of-type(3) em:nth-of-type(2)","parentSelectors":["weibo"],"multiple":false,"regex":"","delay":0},{"id":"rank","type":"SelectorText","selector":"div.WB_feed_handle:nth-of-type(2) li:nth-of-type(4) em:nth-of-type(2)","parentSelectors":["weibo"],"multiple":false,"regex":"","delay":0}]}

不积跬步,无以至千里,先迈出它10步。


转载说明:本文为“三少爷的见”原创文章,转载请务必注明出处。

上一篇下一篇

猜你喜欢

热点阅读