我们为您提供令人难以置信的90%订阅优惠!现在,您可以享受以下无与伦比的价格:
- 专业版: 仅需 **29.9** /月(原价299)
- 企业版: 仅需 **59.9** /月(原价599)
更重要的是,您将通过自动续订继续享受这些折扣!无需额外步骤——您的折扣将在续订时自动应用。
在开始教程之前,让我们首先了解Nstbrowser和Nstbrowser docker是什么。
Nstbrowser是一款强大的指纹浏览器,它为每个用户的帐户提供真实的浏览器环境。每个浏览器彼此隔离,可以实现跨平台环境模拟。基于指纹浏览器技术,它可以轻松绕过各种网站的帐户追踪和检测。
Nstbrowser docker是基于Nstbrowser构建的docker镜像。由于本地资源有限,我们可以通过docker轻松地将Nstbrowser部署到云服务。基于云同步功能,我们可以直接在Nstbrowser docker中使用Nstbrowser创建成熟的浏览器环境。
接下来,我们将演示如何使用Nstbrowser docker自动点赞TikTok(注意:TikTok有严格的账户风险控制预防措施,请尽量不要使用新创建的账户)
docker pull docker.io/nstbrowser/browserless:latest
docker run -d -it \
-e TOKEN="YOUR API KEY" \
-p 8848:8848 \
--name nstbrowserless \
nstbrowser/browserless:latest
这里我们使用puppeteer-core
+ axios
进行演示
# pnpm
pnpm i puppeteer-core axios
# yarn
yarn add puppeteer-core axios
# npm
npm i --save puppeteer-core axios
在使用puppeteer连接到Nstbrowser之前,我们需要先启动Nstbrowser,启动界面:http://localhost:8848/start/{profileId}。您可以在官方网站上查看具体的接口细节和参数:
const baseUrl = 'localhost:8848'
const profileId = 'YOUR_PROFILEID'
async function startBrowser() {
const config = {
"name": "tiktok_star",
"platform": "windows",
"kernel": "chrome",
"kernelMilestone": "130",
// "proxy": "http://127.0.0.1:8000", // 你可以自定义代理
// "fingerprint": { // 配置自定义指纹参数
// "flags": {
// "timezone": "BasedOnIp",
// "screen": "Custom"
// },
// },
// "args": {
// "--proxy-bypass-list": "*.nstbrowser.io" // 配置自定义启动参数
// }
};
return axios.post(`http://${baseUrl}/start/${profileId}`, JSON.stringify((config)), { headers: { 'Content-Type': 'application/json' } })
.then((response) => {
if (response.data.code === 200) {
return true
}
})
.catch((error) => {
console.error(error);
});
}
我们导航到TikTok网站。并通过开发者工具(F12)获取网页中的输入框元素和确定按钮:
输入您要查看的用户内容:
const page = await browser.newPage();
await page.goto('https://www.tiktok.com/');
await page.waitForSelector('input[type=search]')
await page.type('input[type=search]', 'WillSmith', { delay: '100' })
await page.waitForSelector('div.css-1fxbsrz-DivVideoListScrollBar.e10wilco12 > div > div:nth-child(1) a')
await page.click('div.css-1fxbsrz-DivVideoListScrollBar.e10wilco12 > div > div:nth-child(1) a')
有时,进入播放页面时会默认使用小窗口模式。我们需要恢复窗口:
try {
await page.waitForSelector('button.e12q9uh55.css-1xiq6b1-Button-ButtonReturn.e1v8cfre0', { timeout: 3000 });
// close PictureInPicture
await page.click('button.e12q9uh55.css-1xiq6b1-Button-ButtonReturn.e1v8cfre0')
} catch (e) {
console.log("cant find close button")
}
等待视频播放一段时间后再点赞
// wait for the video to play for a while
await new Promise(resolve => setTimeout(resolve, 10000));
// give a like
await page.click('button.css-1mizk9b-ButtonActionItem.e1hk3hf90')
然后滑动视频到下一个并重复此操作:
const boundingBox = await page.$('body video').then(el => el.boundingBox());
for (let i = 0; i < 3; i++) {
// wait for the video to play for a while
await new Promise(resolve => setTimeout(resolve, 10000));
// give a like
await page.click('button.css-1mizk9b-ButtonActionItem.e1hk3hf90')
// move the mouse to the center of the video
await page.mouse.move(
boundingBox.x + boundingBox.width / 2,
boundingBox.y + boundingBox.height / 2
);
// scroll the video down
await page.mouse.wheel({ deltaY: 100 });
}
import puppeteer from 'puppeteer-core';
import axios from 'axios';
const baseUrl = 'localhost:8848'
const profileId = 'YOUR_PROFILEID'
async function startBrowser() {
const config = {
"name": "tiktok_star",
"platform": "windows",
"kernel": "chrome",
"kernelMilestone": "130",
// "proxy": "http://127.0.0.1:8000",
// "doProxyChecking": false,
// "fingerprint": {
// "flags": {
// "timezone": "BasedOnIp",
// "screen": "Custom"
// },
// },
// "args": {
// "--proxy-bypass-list": "*.nstbrowser.io"
// }
};
return axios.post(`http://${baseUrl}/start/${profileId}`, JSON.stringify((config)), { headers: { 'Content-Type': 'application/json' } })
.then((response) => {
if (response.data.code === 200) {
return true
}
})
.catch((error) => {
console.error(error);
});
}
async function execPuppeteer() {
try {
const browser = await puppeteer.connect({
browserWSEndpoint: `ws://${baseUrl}/connect/${profileId}`
});
const page = await browser.newPage();
await page.goto('https://www.tiktok.com/');
await page.waitForSelector('input[type=search]')
await page.type('input[type=search]', 'WillSmith', { delay: '100' })
await page.click('button[data-e2e=search-box-button]')
await page.waitForSelector('div.css-1fxbsrz-DivVideoListScrollBar.e10wilco12 > div > div:nth-child(1) a')
// div.css-1fxbsrz-DivVideoListScrollBar.e10wilco12
await page.click('div.css-1fxbsrz-DivVideoListScrollBar.e10wilco12 > div > div:nth-child(1) a')
try {
await page.waitForSelector('button.e12q9uh55.css-1xiq6b1-Button-ButtonReturn.e1v8cfre0', { timeout: 3000 });
// close PictureInPicture
await page.click('button.e12q9uh55.css-1xiq6b1-Button-ButtonReturn.e1v8cfre0')
} catch (e) {
console.log("cant find close button")
}
await page.waitForSelector('button[data-e2e=arrow-right]')
await page.click('button[data-e2e=arrow-right]')
// get the video bounding box
const boundingBox = await page.$('body video').then(el => el.boundingBox());
for (let i = 0; i < 3; i++) {
// wait for the video to play for a while
await new Promise(resolve => setTimeout(resolve, 10000));
// give a like
await page.click('button.css-1mizk9b-ButtonActionItem.e1hk3hf90')
// move the mouse to the center of the video
await page.mouse.move(
boundingBox.x + boundingBox.width / 2,
boundingBox.y + boundingBox.height / 2
);
// scroll the video down
await page.mouse.wheel({ deltaY: 100 });
}
await browser.close()
} catch (e) {
console.error(e)
}
}
(async () => {
const ok = await startBrowser()
if (ok) {
await execPuppeteer()
}
})();
Nstbrowser的云同步功能可以在任何设备上创建配置文件,并将配置文件同步到其他设备和docker环境。
云同步可以保留您上次访问页面的内容和历史记录,大大简化操作成本。并且在任何设备上相同的配置文件环境都是一样的,可以防止网站的设备检测。云同步Cookie可以将用户的Cookie数据同步在一起,基于Cookie的登录状态也可以同步到相同的配置文件环境。