微信群成员统计
微信群成员统计
微信网页登录
浏览器执行脚本
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
let membersDiv = document.querySelector('.members_inner');
let images = membersDiv.getElementsByClassName('avatar');
async function observeMutation(targetNode) {
const config = { childList: true, subtree: true };
return new Promise(resolve => {
const observer = new MutationObserver((mutationsList) => {
for(let mutation of mutationsList) {
if (mutation.type === 'childList') {
let mmpop_profile = document.querySelector('#mmpop_profile');
if (mmpop_profile) {
let nicknameElement = mmpop_profile.querySelector('.nickname.ng-binding');
if (nicknameElement) {
resolve(nicknameElement.innerText);
observer.disconnect();
}
}
}
}
});
observer.observe(targetNode, config);
});
}
async function performClicks(images) {
for(let i = 0; i < images.length; i++) {
let beforeChanges = images[i].nextElementSibling.innerText;
images[i].click();
let afterChanges = await observeMutation(document.body);
console.error(beforeChanges + ',' + afterChanges);
await new Promise(r => setTimeout(r, 10));
}
}
performClicks(images);
保存log到/tmp/xxx.log
文件
1
2
3
4
5
6
filename = '/tmp/xxx.log'
with open(filename, 'r') as file:
lines = [line for line in file if ',' in line]
with open('/tmp/new.csv', 'w') as output_file:
output_file.writelines(lines)
最后使用VIM进行文本处理成csv即可
This post is licensed under CC BY 4.0 by the author.