Chúng tôi có một ưu đãi đăng ký giảm giá 90% tuyệt vời dành riêng cho bạn!
Giờ đây, bạn có thể tận hưởng các mức giá không thể tốt hơn sau:
- Gói Professional: Chỉ $29.9/tháng (giá gốc $299)
- Gói Enterprise: Chỉ $59.9/tháng (giá gốc $599)
Hơn nữa, bạn sẽ tiếp tục được hưởng những ưu đãi này với tính năng tự động gia hạn! Không cần thêm bước nào nữa—giảm giá của bạn sẽ được tự động áp dụng khi gia hạn.
Trước khi bắt đầu hướng dẫn, trước tiên hãy cùng tìm hiểu Nstbrowser và Nstbrowser docker là gì.
Nstbrowser là một trình duyệt dấu vân tay mạnh mẽ cung cấp môi trường trình duyệt thực cho mỗi tài khoản người dùng. Mỗi trình duyệt được cô lập với nhau và có thể đạt được mô phỏng môi trường đa nền tảng. Dựa trên công nghệ trình duyệt dấu vân tay, nó có thể dễ dàng bỏ qua việc theo dõi tài khoản và phát hiện của các trang web khác nhau.
Nstbrowser docker là một hình ảnh docker được xây dựng dựa trên Nstbrowser. Do tài nguyên cục bộ bị hạn chế, chúng ta có thể dễ dàng triển khai Nstbrowser lên các dịch vụ đám mây thông qua docker. Dựa trên chức năng đồng bộ đám mây, chúng ta có thể trực tiếp sử dụng Nstbrowser trong Nstbrowser docker để tạo môi trường trình duyệt đã được chuẩn bị.
Tiếp theo, chúng ta sẽ trình bày cách sử dụng Nstbrowser docker để tự động click like TikTok (Lưu ý: TikTok có biện pháp phòng ngừa kiểm soát rủi ro tài khoản nghiêm ngặt, vui lòng cố gắng không sử dụng các tài khoản mới tạo)
docker pull docker.io/nstbrowser/browserless:latest
docker run -d -it \
-e TOKEN="YOU API KEY" \
-p 8848:8848 \
--name nstbrowserless \
nstbrowser/browserless:latest
Ở đây chúng ta sử dụng puppeteer-core
+ axios
để trình bày
# pnpm
pnpm i puppeteer-core axios
# yarn
yarn add puppeteer-core axios
# npm
npm i --save puppeteer-core axios
Trước khi sử dụng puppeteer để kết nối với Nstbrowser, chúng ta cần khởi động Nstbrowser trước, khởi động giao diện: http://localhost:8848/start/{profileId}. Bạn có thể kiểm tra chi tiết giao diện và thông số cụ thể trên trang web chính thức:
const baseUrl = 'localhost:8848'
const profileId = 'YOU_PROFILEID'
async function startBrowser() {
const config = {
"name": "tiktok_star",
"platform": "windows",
"kernel": "chrome",
"kernelMilestone": "130",
// "proxy": "http://127.0.0.1:8000", // You can use custom proxy
// "fingerprint": { // configure custom fingerprint parameters
// "flags": {
// "timezone": "BasedOnIp",
// "screen": "Custom"
// },
// },
// "args": {
// "--proxy-bypass-list": "*.nstbrowser.io" // configure custom start parameters
// }
};
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);
});
}
Chúng ta điều hướng đến trang web TikTok. Và lấy phần tử hộp nhập liệu và nút OK trên trang web thông qua công cụ dành cho nhà phát triển (F12):
Nhập nội dung người dùng bạn muốn xem:
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')
Đôi khi, khi vào trang phát lại, chế độ cửa sổ nhỏ sẽ được sử dụng theo mặc định. Chúng ta cần khôi phục cửa sổ:
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")
}
Chờ video phát một lúc rồi thích nó
// 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')
Sau đó trượt video sang video tiếp theo và lặp lại thao tác này:
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 = 'YOU_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()
}
})();
Chức năng đồng bộ đám mây của Nstbrowser có thể tạo hồ sơ trên bất kỳ thiết bị nào và đồng bộ hồ sơ đó với các thiết bị và môi trường docker khác.
Đồng bộ đám mây có thể giữ lại nội dung và lịch sử của trang bạn truy cập lần cuối, giúp đơn giản hóa đáng kể chi phí hoạt động. Và cùng một môi trường hồ sơ giống nhau trên mọi thiết bị, điều này có thể ngăn chặn việc phát hiện thiết bị trên trang web. Cookie đồng bộ đám mây có thể đồng bộ dữ liệu cookie người dùng cùng nhau, và trạng thái đăng nhập dựa trên cookie cũng có thể được đồng bộ với cùng một môi trường hồ sơ.