企业🤖AI Agent构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
# 油猴脚本 引入大脚包 实现自动数据下载 ``` // ==UserScript== // @name bilibili 搜索 // @namespace http://tampermonkey.net/ // @version 0.1 // @description try to take over the world! // @author You // @match https://search.bilibili.com/all?keyword=vue%E5%AE%9E%E7%8E%B0%E5%8F%8C%E5%90%91%E7%BB%91%E5%AE%9A&from_source=webtop_search&spm_id_from=333.1007 // @icon https://www.google.com/s2/favicons?domain=bilibili.com // @require 这里是脚本url // @grant none // ==/UserScript== (function() { 'use strict'; new Lue({ data: { arr : [], page : 0 }, mounted() { this.nowPageGet() }, methods: { nowPageGet(){ this.page++ this.ifExist('.pagination-btn').then(res => { // console.log(res.innerText) res.forEach( (data,page) => { if(data.innerText == this.page){ // 点击跳转到页面 console.log('点击第:'+ this.page +'页') data.click() setTimeout( () => { // this.getData() console.log('加载完毕') this.ifExist('.title').then(r0 => { console.log('获取完毕',r0) this.ifExist('.watch-num').then(r1 => { console.log('获取完毕',r1) this.ifExist('.time').then(r2 => { console.log('获取完毕',r2) this.ifExist('.up-name').then(r3 => { console.log('获取完毕',r3) this.ifExist('.so-imgTag_rb').then(r4 => { console.log('获取完毕',r4) // 数据现在已经存好了 let arrData = [] r4.forEach( (data,i) => { // console.log('数据遍历',data) let aaJson = {} aaJson.title = r0[i+1].innerText aaJson.see = r1[i].innerText aaJson.up_time = r2[i].innerText aaJson.user = r3[i].innerText aaJson.video_time = r4[i].innerText // 将生成对象付给数组 arrData.push(aaJson) }) console.log(arrData) this.saveDataAll('elasticsearch_data',arrData) this.nowPageGet() }) }) }) }) }) // this.getData() },3000) } }) }) }, getData() { this.page++ this.ifExist('.pagination-btn').then(res => { // 获取按钮 点击 累加点击 res.forEach( (data,page) => { if(data.innerText == this.page){ // 点击跳转到页面 console.log('点击第:'+ this.page +'页') // 点击第一页 data.click() // 开始 console.log('跳转成功') this.ifExist('.title').then(r0 => { console.log('数据:',r) this.ifExist('.watch-num').then(r1 => { this.ifExist('.up-name').then(r3 => { this.ifExist('.so-imgTag_rb').then(r4 => { this.ifExist('.time').then(r2 => { // console.log(r0, r1, r2) var myArr = [] r0.forEach((res,i) => { // console.log(r0[i].innerText,r1[i].innerText,r2[i].innerText,r3[i].innerText) let aaJson = {} aaJson.title = r0[i].innerText aaJson.see = r1[i].innerText aaJson.up_time = r2[i].innerText aaJson.user = r3[i].innerText aaJson.video_time = r4[i].innerText // 数组添加 // console.log('数组添加') myArr.push(aaJson) }) console.log('怎么回事') this.saveDataAll('bilibili_all_data',myArr) }) }) }) }) }) // 结束 } }) }) } } }) // Your code here... })(); ```