// ==UserScript== // @name Extract Weibo Fans ID // @namespace http://tampermonkey.net/ // @version 1.0 // @description Extract Weibo Fans ID and save to a text file using the fans interface and page incrementing loop // @author Your name // @match https://weibo.com/* // @grant GM_xmlhttpRequest // ==/UserScript==

(function() { 'use strict';

// Set the starting page number and initialize an empty array to store the fan IDs
let page = 1;
let fanIds = [];

// Define the function to extract fan IDs from the API response
const extractFanIds = (responseText) => {
    let jsonData = JSON.parse(responseText);
    let fans = jsonData.users;
    for (let fan of fans) {
        fanIds.push(fan.id);
    }
}

// Define the function to write the fan IDs to a text file
const saveFanIdsToFile = () => {
    let fanIdsText = fanIds.join('

'); let blob = new Blob([fanIdsText], {type: 'text/plain'}); let url = URL.createObjectURL(blob); let link = document.createElement('a'); link.href = url; link.download = 'weibo_fan_ids.txt'; link.click(); }

// Define the function to send the API request and extract fan IDs
const getFanIds = () => {
    let url = `https://weibo.com/ajax/friendships/friends?relate=fans&page=${page}&uid=3977639513&type=fans&newFollowerCount=0`;
    GM_xmlhttpRequest({
        method: 'GET',
        url: url,
        onload: function(response) {
            extractFanIds(response.responseText);
            if (page < 100) { // Set the maximum number of pages here
                page++;
                setTimeout(getFanIds, 500); // Set the delay between requests here
            } else {
                saveFanIdsToFile();
            }
        }
    });
}

// Execute the getFanIds function to start the loop
getFanIds();

})();

微博粉丝ID提取脚本 - 油猴脚本自动获取所有粉丝数据

原文地址: https://www.cveoy.top/t/topic/n2zQ 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录