美文网首页
别再被营销号骗流量了。关于瑞幸,你可能真的没看懂

别再被营销号骗流量了。关于瑞幸,你可能真的没看懂

作者: 数云智连 | 来源:发表于2019-04-23 22:18 被阅读0次

    友情提示:

    技术流文章,文科生请绕道,以免烧脑。

    隔几天就能看到瑞幸烧钱、亏损,活不长的消息满屏飞。

    既然有免费赠送体验券,那咱肯定要去试一试对不对。万一哪天就不送了呢。
    说干就干,抓取手机、搜下瑞幸的微信小程序,输入下手机号码就注册好了,挺便捷的。完成后就收到一堆优惠券了。

    有券任性,开始买买买:
    第一杯,焦糖玛奇朵半糖,不知道是糖太少还是奶盖太少,又苦又涩,说实话真不懂,跟以往其他奶茶店喝的焦糖玛奇朵比起来是完全不同,我都怀疑喝的是假咖啡;
    第二杯,百香芒果瑞纳冰;第三杯,抹茶拿铁;第四杯,NFC鲜榨蓝莓草莓混合果汁,感觉都还也不错啊,原谅我读书少刚开始不知道NFC代表啥,难道是像手机那样的刷公交卡。几个人买几瓶可以在那滴滴滴互动?淘宝上搜了下,才发现是学名是“非浓缩还原汁”,绕这么大一圈。公司里很多小姐姐超喜欢这款,预计会火。然后接着第五、六、七杯都还不错,没网上看到说的那么不堪。

    为了证明这个结论,上爬虫到微博抓取些评论来做下情感评论分析,对于瑞幸的评论好不好,让大众评价说话。

    1、爬虫抓取微博关键词"瑞幸"评论

    循环翻页爬取关于瑞幸的所有评论内容。结果存入excel,待查看评价内容,读取后做情感评价分析。

    #微博爬虫:https://s.weibo.com/,按“瑞幸”搜索
    from selenium import webdriver
    from lxml import etree
    import time,datetime,xlwt,xlrd,os,re
    from xlutils.copy import copy
    from urllib import parse
                    
    def parse_time(time_str):
        if '分钟前' in time_str:
            time_temp = int(time_str.split('分钟前')[0])
            new_time = (datetime.datetime.now() + datetime.timedelta(minutes=time_temp)).strftime("%Y-%m-%d %H:%M")
        elif '今天' in time_str:
            time_temp = time_str.split('今天')[1]
            new_time = (datetime.datetime.now()).strftime("%Y-%m-%d") + ' ' +time_temp
        elif '月' in time_str and '日' in time_str:
            time_temp = time_str.replace('月','-').replace('日','-')
            new_time = (datetime.datetime.now()).strftime("%Y") + '-' +time_temp
        else:
            new_time=''
        return new_time
    
    # 创建excel表
    def create_wookbook(sheetheader):
        workbook = xlwt.Workbook()
        worksheet = workbook.add_sheet('weibo')
        # 写入表头
        for h in range(0, len(sheetheader)):
            worksheet.write(0, h, sheetheader[h])
        workbook.save('weibo.xls')
    
    # 写入数据  
    def write_into_workbook(rows, content_info_list):
        oldWb = xlrd.open_workbook('weibo.xls')  # 先打开已存在的表
        newWb = copy(oldWb)  # 复制
        newWs = newWb.get_sheet(0)  # 取sheet表
        for ex in content_info_list:
            for col in range(0, len(ex)):
                newWs.write(rows, col, ex[col])
            rows += 1
        newWb.save('weibo.xls')
        return rows
    
    def weibo(key_word,user_name,user_key,pages):
        dict_weibo ={'q':key_word,'wvr':'6','b':'1','Refer':'SWeibo_box'}
    
        print('采集关键词:{},采集页数:{}'.format(key_word,pages))
        start_url = 'https://s.weibo.com/weibo?'+parse.urlencode(dict_weibo)
        sheetheader = ['编号', '用户名', '用户链接', '会员类型', '评论内容', '评论时间', '来自','转发','评论','点赞']
        if not os.path.exists('weibo.xls'):
            create_wookbook(sheetheader)
        rows =1
        driver = webdriver.Chrome()
        driver.get('https://s.weibo.com/')
        time.sleep(2)
        html = etree.HTML(driver.page_source)
        if html.xpath('//*[@id="weibo_top_public"]/div/div/div[3]/div[2]/ul/li[3]/a'):
            driver.find_element_by_xpath('//*[@id="weibo_top_public"]/div/div/div[3]/div[2]/ul/li[3]/a').click()
    
        time.sleep(2)
        input_user = driver.find_element_by_xpath('.//input[@action-data="text=邮箱/会员帐号/手机号"]')
        time.sleep(2)
        input_user.clear()
        input_user.send_keys(user_name)#输入账号
        time.sleep(2)
        input_key = driver.find_element_by_xpath('.//input[@type="password"]')
        input_key.clear()
        input_key.send_keys(user_key)#输入密码
        driver.find_element_by_xpath('.//span[@class="enter_psw"]/../../div[@class="item_btn"]/a').click() #点击登录
        time.sleep(2)
    
        for page in range(1,pages+1):
            url = (start_url+'&page={}').format(page)
            driver.get(url)  
            html = etree.HTML(driver.page_source)
            item = html.xpath('.//div[@class="card-wrap" and @action-type="feed_list_item"]')
            content_info = {}
            content_info_list = []
            for i in item:
                # content_info['page'] = page
                content_info['mid'] = "".join(i.xpath('./@mid')).strip()
                content_info['user_name'] = "".join(i.xpath('.//descendant::div[@class="content"]/div/div/a[@class="name"]/@nick-name')).strip()
                content_info['user_link'] = 'https:'+"".join(i.xpath('.//descendant::div[@class="content"]/div/div/a[@class="name"]/@href')).strip().split('?re')[0]
                content_info['user_type'] = "".join(i.xpath('.//descendant::div[@class="content"]/div/div/a[@target="_blank" and @title]/@title')).strip()
                content_info['content_txt'] = "".join(i.xpath('.//descendant::div[@class="content"]/p[@class="txt"][position()=last()]//text()')).strip()
                content_info['content_time'] = "".join(i.xpath('.//descendant::div[@class="content"]/p[@class="from"]/a[@suda-data]/text()')).strip()
                if content_info['content_time'] == '':
                    content_info['content_time'] = ''
                else:
                    content_info['content_time'] = parse_time(content_info['content_time'])
                content_info['phone_nofollow'] = "".join(i.xpath('.//descendant::div[@class="content"]/p[@class="from"]/a[@rel="nofollow"]/text()')).strip()
                content_info['content_zhuanfa'] = "".join(i.xpath('.//descendant::div[@class="card-act"]/ul/li[2]//text()')).strip().replace('转发','')
                content_info['content_pinglu'] = "".join(i.xpath('.//descendant::div[@class="card-act"]/ul/li[3]//text()')).strip().replace('评论','')
                content_info['content_dianzan'] = "".join(i.xpath('.//descendant::div[@class="card-act"]/ul/li[4]//text()')).strip().replace('赞','')
                
         
                content_info_list.append(list(content_info.values()))
            print(content_info_list)
            rows = write_into_workbook(rows, content_info_list)
            time.sleep(2)
        print('采集完成')
        driver.close()
    if __name__ =='__main__':
        key_word = input('请输入采集关键词:')
        user_name = input('请输入微博用户名:')
        user_key = input('请输入微博密码:')
        pages = 50 #采集页数
        weibo(key_word,user_name,user_key,pages)
    
    

    2、读取评价列表,调用百度情感评价api分析每一条评价得分

    #情感评分分析
    from aip import AipNlp
    import csv,re
    import pandas as pd
    import numpy as np
    
    """ 你的 APPID AK SK """
    # 利用百度云提供的API接口实现情感分析
    APP_ID = ''
    API_KEY = ''
    SECRET_KEY = ''
    client = AipNlp(APP_ID, API_KEY, SECRET_KEY)
    
    #清洗Unicode编码字符串https://www.jianshu.com/p/4958bcdea12a
    def illegal_char(s):
        s = re.compile( \
            u"[^"
            u"\u4e00-\u9fa5"
            u"\u0041-\u005A"
            u"\u0061-\u007A"
            u"\u0030-\u0039"
            u"\u3002\uFF1F\uFF01\uFF0C\u3001\uFF1B\uFF1A\u300C\u300D\u300E\u300F\u2018\u2019\u201C\u201D\uFF08\uFF09\u3014\u3015\u3010\u3011\u2014\u2026\u2013\uFF0E\u300A\u300B\u3008\u3009"
            u"\!\@\#\$\%\^\&\*\(\)\-\=\[\]\{\}\\\|\;\'\:\"\,\.\/\<\>\?\/\*\+"
            u"]+").sub('', s)
        return s
    
    # 对读入的数据进行情感分析,将其得到的结果解析成标准JSON格式数据,并保存在一个新的dict中
    def senti_anlaly(text):
        text = illegal_char(text)
        data = client.sentimentClassify(text)
        sentiment =data['items'][0]['positive_prob']
        return sentiment
    
    datas = pd.read_excel('weibo_luckin.xls',sheet_name='weibo',header=0,encoding = "gbk")
    sentiments = []
    for s in list(datas['评论内容']):
        sentiments.append(senti_anlaly(s))
    

    3、分析情感评价得分

    评价平均分、中位数:

    print('情感评分平均得分:'+str(np.mean(sentiments)))
    print('情感评分中位数:'+str(np.median(sentiments)))
    

    情感评分平均得分:0.697;情感评分中位数:0.806

    直方图分布:

    from matplotlib import pyplot
    import math
    grades =[]
    for s in sentiments:
        grades.append(math.ceil(s*10)/10) 
     
    #绘制直方图
    def drawHist(sentiments):
        #创建直方图
        #第一个参数为待绘制的定量数据,不同于定性数据,这里并没有事先进行频数统计
        #第二个参数为划分的区间个数
        x =[i/10 for i in range(1,11,1)]
        pyplot.hist(sentiments, 10)
        pyplot.xticks(x)
        pyplot.xlabel('score')
        pyplot.ylabel('Frequency')
        pyplot.title('luckin weibo sentiment score')
        pyplot.figure(figsize=(12, 12))
        pyplot.show()
    drawHist(grades)
    

    按0.1等间距划分分布,可以很明显的看到情感评分得分集中分布在0.7-1分,且0.9-1分数量还是最多的,超过300个,将近1/3(因微博只能查看前50页,只能爬1000条数据)。

    累计柱形图:

    from matplotlib import pyplot
    
    #绘制累积曲线
    def drawCumulativeHist(sentiments):
        #创建累积曲线
        #第一个参数为待绘制的定量数据
        #第二个参数为划分的区间个数
        #normed参数为是否无量纲化
        #histtype参数为'step',绘制阶梯状的曲线
        #cumulative参数为是否累积
        x =[i/10 for i in range(1,11,1)]
        pyplot.hist(sentiments, 10, normed=True, histtype='step', cumulative=True)
        pyplot.xticks(x)
        pyplot.xlabel('score')
        pyplot.ylabel('Frequency')
        pyplot.title('luckin weibo sentiment score')
        pyplot.show()
    drawCumulativeHist(grades)
    

    累计柱形图中:0.7分以上占了60%。



    百度的这个情感倾向分析,0.5-0.7有一些误判的,明明是负向的,评到了0.6-0.7几。但是0.8以上基本误判的就比较少了,加上有些高分误判到低分的。相互抵消下,这个情感倾向评分结果是很有具有说服力的。

    直观的数据结果,会出乎大多数人意外。瑞幸,其实比你想象中的要好。

    网上关于瑞幸的负面评价,大多数是有失公允的。如果再去看下负面评价的来源,大多是营销号在带节奏。
    把瑞幸类比ofo的,其实也是站不住脚的,ofo没骑两三次就坏了,大量的亏损至破产来源小黄车的损坏。而瑞幸店面会坏吗?还是瑞幸服务员会坏?
    瑞幸更像的是滴滴模式,亏损来源于前期获取用户的补贴,0元免费送一杯、2.8折一杯、以及一堆5折券、去年的买一送二、买五送五等活动。
    http://dy.163.com/v2/article/detail/EDELPID30511WT04.html
    看下刚公布的几个数据


    (连星巴克的股东都跑来投资瑞幸了)

    瑞幸到2019Q1累计亏损21.7亿,用户数1687万。实际上亏损来源于新客补贴、大量买一送二、累计抽红包等活动。等新用户数增长到一定数量,新客变老客,瑞幸自然也不需要再花那么大的价钱获取新客了。
    今年新客成本降到16.9元,这个数字很值得推敲,因为今年注册新用户的优惠券是:0元免费送、2.8折、以及一堆5折券。会让瑞幸亏损的最多的是0元免费送一杯、2.8折一杯送的。假设获客成本都是0元、2.8折来的,平均一杯亏:16.9/(1+(1-0.28))=9.8元,就是说一杯成本才10元左右(如果5折里还有获客成本,那单杯成本就是16.9/(1+(1-0.28)+n0+n1+……),成本还要更低)。瑞幸咖啡、饮料售价在24-27,即使按5折售卖,也大概就能盈亏平衡了。
    http://www.luckinjm.com/news/22.html(瑞幸官网上自己公布的数据,算完才找到的-_-|||,扣掉租金、设备折旧、人工(北京比较贵)、水电,跟上面算出的9.8接近。)

    瑞幸现在app、小程序上的是优惠是什么?充二送一、66折,实际上按这个折扣力度已经能让瑞幸盈利。如果不再需要为了大量获取新客补贴,盈利还会远吗?那些说瑞幸是下一个ofo的可以歇歇了。

    相关文章

      网友评论

          本文标题:别再被营销号骗流量了。关于瑞幸,你可能真的没看懂

          本文链接:https://www.haomeiwen.com/subject/wmvbgqtx.html