美文网首页
B站弹幕和评论提取

B站弹幕和评论提取

作者: 年画儿 | 来源:发表于2019-08-07 10:19 被阅读0次

    弹幕接口可以通过b站 转换到手机端获取
    弹幕接口:https://comment.bilibili.com/108577248.xml
    利用正则表达式提取弹幕

    import requests
    import re
    
    url = "https://comment.bilibili.com/108577248.xml"
    r = requests.get(url)
    # print(r.content.decode("utf-8"))
    
    # ret = re.findall(r'<d(.*?)/d>',r.content.decode("utf-8"))
    #' p="385.97600,1,25,16777215,1565097766,0,3fa6c8ee,19899661036290052">弹幕呢?<'
    
    ret = re.findall(r'<d\sp=.*?>(.*?)</d>',r.content.decode("utf-8"))
    print(ret)
    

    评论接口:https://api.bilibili.com/x/v2/reply?callback=jQuery172019546611572247063_1565144626762&jsonp=jsonp&pn=1&type=1&oid=62477597&sort=0&_=1565144628678

    相关文章

      网友评论

          本文标题:B站弹幕和评论提取

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