Last active
December 5, 2025 09:45
-
-
Save wjx0912/cccc1b48caa3a525e79604ea8d6f79cf to your computer and use it in GitHub Desktop.
v2ex dau refresh (闷声发大财就行了,不要宣传,不要宣传,不要宣传)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function formatDate (date) { | |
| const pad = (n) => n.toString().padStart(2, '0') | |
| return [ | |
| date.getFullYear(), | |
| pad(date.getMonth() + 1), | |
| pad(date.getDate()) | |
| ].join('-') + ' ' + | |
| [ | |
| pad(date.getHours()), | |
| pad(date.getMinutes()), | |
| pad(date.getSeconds()) | |
| ].join(':') | |
| } | |
| async function get_dau (username) { | |
| try { | |
| const html = await (await fetch("https://www.v2ex.com/member/" + username, { | |
| "referrer": "https://www.v2ex.com/balance", | |
| "body": null, | |
| "method": "GET", | |
| "mode": "cors", | |
| "credentials": "include" | |
| })).text() | |
| const match = html.match(/今日活跃度排名\s*<a[^>]*>(\d+)<\/a>/) | |
| if (match) { | |
| dau = parseInt(match[1], 10) | |
| console.log('当前活跃度: ', dau) | |
| return dau | |
| } | |
| } catch (error) { | |
| console.error('Error refreshing DAU:', error) | |
| } | |
| return 0 | |
| } | |
| async function refresh (username, threshold, sleep) { | |
| while (true) { | |
| const dau = await get_dau(username) | |
| if (dau <= threshold) { | |
| console.log(`活跃度已达到 ${dau},停止刷新。`) | |
| break | |
| } | |
| console.log(formatDate(new Date()) + `:当前用户 ${username} 活跃度为 ${dau},未达到阈值 ${threshold},休眠${sleep}秒继续刷新...`) | |
| await new Promise(resolve => setTimeout(resolve, sleep * 1000)) | |
| } | |
| } | |
| // 第一个参数是用户名,第二个参数是需要的活跃度阈值,第三个参数是休眠时间值越大越好以免意外封号(单位秒) | |
| // dau排行榜: https://www.v2ex.com/top/dau | |
| refresh('datadump', 10, 60) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment