B站获取up主投稿数据

此插件用于获取B站up主投稿列表数据,附带导出Excel网站

当前为 2021-11-23 提交的版本,查看 最新版本

// ==UserScript==
// @name         B站获取up主投稿数据
// @namespace    http://tampermonkey.net/
// @version      1.0
// @description  此插件用于获取B站up主投稿列表数据,附带导出Excel网站
// @author       You
// @include      https://space.bilibili.com/*
// @icon         https://space.bilibili.com/favicon.ico
// @grant        none
// @require      http://code.jquery.com/jquery-1.11.0.min.js
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    setTimeout(() => {
        let videoList = []
        let totalPage = 0
        let nowPage = 0
        $('.page-head__left').append(`<button id="startCalc">开始导出</button>`)
        $(document).on('click', '#startCalc', function() {
          nowPage = parseInt($('.be-pager-item-active').attr('title').split(':')[1])
          totalPage = parseInt($('.be-pager-total').text().split('共 ')[1].split(' 页,')[0])
          startCalc()
        })
        $(document).on('click', '#checkResult', function() {
          $('.page-head__left').append(`<textarea id="dataText" value="" type="text"></textarea><a href="https://data.page/json/csv" target="blank">导出Excel</a>`)
          $('#dataText').val(JSON.stringify(videoList))
        })
        function startCalc() {
          console.log(nowPage)
          if (nowPage > totalPage) {
            $('.page-head__left').append(`<textarea id="dataText" value="" type="text"></textarea><a href="https://data.page/json/csv" target="blank">导出Excel</a>`)
            $('#dataText').val(JSON.stringify(videoList))
            return
          }
          for (let i = 0; i < $('.list-list').children('.list-item').length; i++) {
              const element = $('.list-list').children('.list-item').eq(i)
              let title = element.children('.c').children('.title-row').children('.title').attr('title')
              let href = element.children('.c').children('.title-row').children('.title').attr('href')
              let desc = element.children('.c').children('.desc').attr('title')
              let play = element.children('.c').children('.meta').children('.play').text().split('\n')[0]
              let bulletComments = element.children('.c').children('.meta').children('.comments').text().split('\n')[0]
              videoList.push({
                title: title,
                href: href,
                desc: desc,
                play: play,
                bulletComments: bulletComments
              })
          }
          // loopCheck()
          $('.be-pager-next').click()
          nowPage++
          console.log(videoList)
          setTimeout(() => {
            startCalc()
          }, 1000)
        }
    }, 2000)
})();