Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- nama : idk, backlink maybe?
- base : https://free-seo-tools.seomator.com
- by : wolep
- update : 9 November 2025, 23:50 WITA
- node : v25.0.0
- note : kali ini perlu library cheerio, gw gk bs aslinya :v
- kode nya gw minta ke ai di fungsi parseHTML :v
- request an orang.. bang syaii
- module : esm (tested) / cjs (gak tau coba test yah :v)
- */
- import * as cheerio from 'cheerio'
- const seo = {
- static: Object.freeze({
- baseUrl: 'https://free-seo-tools.seomator.com',
- baseheaders: {
- 'accept-encoding': 'gzip, deflate, br, zstd',
- 'user-agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/142.0.0.0 Safari/537.36 Edg/142.0.0.0'
- }
- }),
- helper: {
- log: function (message) {
- // return
- console.log(`[seo] ${message}`)
- },
- formatError: function (string) {
- const MAX_LENGTH = 200
- const type = typeof (string)
- if (type !== "string") return `(gak bisa nampilin teks karena type yg di kasih adalah ${type})`
- if (!string) return '(empty message)'
- let message = string
- try {
- message = JSON.stringify(JSON.parse(string), null, 2)
- } catch (_) { }
- if (message.length > MAX_LENGTH) {
- message = message.substring(0, MAX_LENGTH) + `... (trimmed ${string.length - MAX_LENGTH} characters)`
- }
- return message
- }
- },
- getCookie: async function () {
- this.helper.log('ambil kuki')
- const r = await fetch(this.static.baseUrl, { headers: this.static.baseheaders })
- if (!r.ok) throw Error(`${r.status} ${r.statusText} di fungsi getCookie\n${this.helper.formatError(await r.text())}`)
- const c = r.headers.getSetCookie()
- const cookie = c.map(v => v.split("; ")[0]).join("; ")
- return { cookie }
- },
- apiBackLink: async function (url, cookie) {
- this.helper.log('hit api')
- const api = new URL('/tool.php', this.static.baseUrl)
- api.search = new URLSearchParams({
- id: 'high-quality-backlinks',
- site: url,
- exp: Math.floor((Date.now() + 43200000) / 1000) // 12 hours ahead from now time (in seconds)
- })
- const headers = {
- cookie,
- ...this.static.baseheaders
- }
- const r = await fetch(api, { headers });
- if (!r.ok) throw Error(`${r.status} ${r.statusText} di fungsi apiBacklink\n${this.helper.formatError(await r.text())}`)
- const html = await r.text()
- return { html }
- },
- parseHtml: function (html) {
- this.helper.log('parsing html')
- const $ = cheerio.load(html);
- // Cari tabel dengan id 'backlinks'
- const rows = $("#backlinks tbody tr");
- const result = [];
- rows.each((i, el) => {
- const $row = $(el);
- // ambil kolom satu-satu
- const index = $row.find("td:nth-child(1)").text().trim();
- const pageTitle = $row.find('td[data-split="title,url"] [data-key="title"]').text().trim();
- const pageUrl = $row.find('td[data-split="title,url"] [data-key="url"]').text().trim();
- const anchorTitle = $row.find('td[data-split="title,url,nofollow"] [data-key="title"]').text().trim();
- const anchorUrl = $row.find('td[data-split="title,url,nofollow"] [data-key="url"]').text().trim();
- const pa = $row.find("td:nth-child(4) .value").text().trim();
- const da = $row.find("td:nth-child(5) .value").text().trim();
- const found = $row.find("td:nth-child(6)").text().trim();
- result.push({
- index,
- pageTitle,
- pageUrl,
- anchorTitle,
- anchorUrl,
- pa,
- da,
- found,
- });
- });
- return { result }
- },
- backlink: async function (url) {
- if (!url) throw Error(`param url gak boleh kosong`)
- const { cookie } = await this.getCookie()
- const { html } = await this.apiBackLink(url, cookie)
- const { result } = this.parseHtml(html)
- this.helper.log('done')
- return result
- }
- }
- // cara pakai
- seo.backlink('https://api.paxsenix.org')
- .then(console.log)
- .catch(console.log)
- /* output
- [
- {
- index: '1',
- pageTitle: 'Sketchub • alex_',
- pageUrl: 'https://web.sketchub.in/u/alex_',
- anchorTitle: 'https://api.paxsenix.org/docs',
- anchorUrl: 'https://api.paxsenix.org/docs',
- pa: '0',
- da: '32',
- found: '2025-10-10'
- }
- ]
- */
Advertisement
Add Comment
Please, Sign In to add comment