操作1:获取抖音的昵称、抖音号、头像、平台
采用automa插件,具体的详细操作可以参考释放你的时间:自动发布小红书的全面指南-CSDN博客
- 选择“触发器”
- 选择“新建标签页”,填写抖音主页的URL
- 选择“JavaScript”,编写js代码
-
var same_query = '#douyin-right-container > div:nth-of-type(2) > div > div > div:nth-of-type(2) >' // 获取头像 var getImageTag = document.querySelector(same_query + 'div:nth-of-type(1) > div > img') var getImageContent = '' if (getImageTag) { getImageContent = getImageTag.getAttribute('src') console.log(getImageContent) } else { console.log('未找到头像元素') } // 获取平台 var getPlatFormContent = window.location.host console.log(getPlatFormContent) // 获取抖音号 var getAccountTag = document.querySelector(same_query + 'div:nth-of-type(2) > p > span:nth-of-type(1)') var getAccountContent = '' if (getAccountTag) { getAccountContent = getAccountTag.textContent.trim().match(/抖音号:(.+)/)[1] console.log(getAccountContent) } else { console.log('未找到抖音号元素') } // 获取昵称 var getNickNameTag = document.querySelector(same_query + 'div:nth-of-type(2) > div:nth-of-type(1) > h1 > span > span > span > span > span > span') var getNickNameContent = '' if (getNickNameTag) { getNickNameContent = getNickNameTag.textContent.trim() console.log(getNickNameContent) } else { console.log('未找到昵称元素') } var data = { image: getImageContent, platform: getPlatFormContent, account: getAccountContent, nickname: getNickNameContent }; var xhr = new XMLHttpRequest(); xhr.open('POST', 'http://域名:端口号/xxx', true); xhr.setRequestHeader('Content-Type', 'application/json'); xhr.onload = function () { if (xhr.status == 200) { console.log('数据发送成功'); } else { console.error('数据发送失败'); } }; xhr.send(JSON.stringify(data));