nondanee / weiboBatchFollow

微博批量关注 (转移关注列表)
MIT License
232 stars 30 forks source link

因为某些原因不能登录移动版微博,当时能登录电脑版微博,这种情况下怎么样获取关注列表? #23

Open xingpingcn opened 1 year ago

xingpingcn commented 1 year ago

因为某些原因不能登录移动版微博,当时能登录电脑版微博,这种情况下怎么样获取关注列表?

wocattree commented 10 months ago

顶顶,我也是被封号了,移动版微博不能爬取关注列表

BurningUDream commented 10 months ago

@xingpingcn @wocattree 用gpt修改了一版,可以从普通网页提取:https://github.com/BurningUDream/weiboBatchFollow

Crwing commented 9 months ago
(() => {
    const follows = []
    const sleep = time => () => new Promise(resolve => setTimeout(resolve, time))
    const query = page =>
        fetch(
            `/ajax/profile/followContent?page=${page}&next_cursor=50`, 
            { headers: { 'X-XSRF-TOKEN': (document.cookie.match(/XSRF-TOKEN=([^;$]+)/) || [])[1] || '' } }
        ) 
            .then(response => response.json())
            .then(body => {
                const { data, msg, ok } = body
                if (data.follows.users.length == 0) return Promise.reject(new Error('finish'))
                                data.follows.users.forEach(user => user && follows.push(user.id))
            })
    const polling = (page = 1) => query(page).then(sleep(1500)).then(() => polling(page + 1))

    polling()
        .catch(error => console.warn(`${error.message === 'finish' ? '获取完成' : `出错了 (${error.message})` }\n\n${JSON.stringify(follows)}`))
})()

电脑版微博可用