wolfyflutter

68. free-seo-tools.seomator.com [tools]

Nov 9th, 2025
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
JavaScript 4.74 KB | Source Code | 0 0
  1. /*
  2.   nama   : idk, backlink maybe?
  3.   base   : https://free-seo-tools.seomator.com
  4.   by     : wolep
  5.   update : 9 November 2025, 23:50 WITA
  6.   node   : v25.0.0
  7.   note   : kali ini perlu library cheerio, gw gk bs aslinya :v
  8.            kode nya gw minta ke ai di fungsi parseHTML :v
  9.            request an orang.. bang syaii
  10.   module : esm (tested) / cjs (gak tau coba test yah :v)
  11. */
  12.  
  13. import * as cheerio from 'cheerio'
  14.  
  15. const seo = {
  16.     static: Object.freeze({
  17.         baseUrl: 'https://free-seo-tools.seomator.com',
  18.         baseheaders: {
  19.             'accept-encoding': 'gzip, deflate, br, zstd',
  20.             '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'
  21.         }
  22.     }),
  23.  
  24.     helper: {
  25.         log: function (message) {
  26.             // return
  27.             console.log(`[seo] ${message}`)
  28.         },
  29.  
  30.         formatError: function (string) {
  31.             const MAX_LENGTH = 200
  32.             const type = typeof (string)
  33.             if (type !== "string") return `(gak bisa nampilin teks karena type yg di kasih adalah ${type})`
  34.             if (!string) return '(empty message)'
  35.             let message = string
  36.             try {
  37.                 message = JSON.stringify(JSON.parse(string), null, 2)
  38.             } catch (_) { }
  39.             if (message.length > MAX_LENGTH) {
  40.                 message = message.substring(0, MAX_LENGTH) + `... (trimmed ${string.length - MAX_LENGTH} characters)`
  41.             }
  42.             return message
  43.         }
  44.     },
  45.  
  46.     getCookie: async function () {
  47.         this.helper.log('ambil kuki')
  48.         const r = await fetch(this.static.baseUrl, { headers: this.static.baseheaders })
  49.         if (!r.ok) throw Error(`${r.status} ${r.statusText} di fungsi getCookie\n${this.helper.formatError(await r.text())}`)
  50.         const c = r.headers.getSetCookie()
  51.         const cookie = c.map(v => v.split("; ")[0]).join("; ")
  52.         return { cookie }
  53.     },
  54.  
  55.     apiBackLink: async function (url, cookie) {
  56.         this.helper.log('hit api')
  57.         const api = new URL('/tool.php', this.static.baseUrl)
  58.         api.search = new URLSearchParams({
  59.             id: 'high-quality-backlinks',
  60.             site: url,
  61.             exp: Math.floor((Date.now() + 43200000) / 1000) // 12 hours ahead from now time (in seconds)
  62.         })
  63.         const headers = {
  64.             cookie,
  65.             ...this.static.baseheaders
  66.         }
  67.         const r = await fetch(api, { headers });
  68.         if (!r.ok) throw Error(`${r.status} ${r.statusText} di fungsi apiBacklink\n${this.helper.formatError(await r.text())}`)
  69.         const html = await r.text()
  70.         return { html }
  71.     },
  72.  
  73.     parseHtml: function (html) {
  74.         this.helper.log('parsing html')
  75.         const $ = cheerio.load(html);
  76.  
  77.         // Cari tabel dengan id 'backlinks'
  78.         const rows = $("#backlinks tbody tr");
  79.  
  80.         const result = [];
  81.  
  82.         rows.each((i, el) => {
  83.             const $row = $(el);
  84.  
  85.             // ambil kolom satu-satu
  86.             const index = $row.find("td:nth-child(1)").text().trim();
  87.  
  88.             const pageTitle = $row.find('td[data-split="title,url"] [data-key="title"]').text().trim();
  89.             const pageUrl = $row.find('td[data-split="title,url"] [data-key="url"]').text().trim();
  90.  
  91.             const anchorTitle = $row.find('td[data-split="title,url,nofollow"] [data-key="title"]').text().trim();
  92.             const anchorUrl = $row.find('td[data-split="title,url,nofollow"] [data-key="url"]').text().trim();
  93.  
  94.             const pa = $row.find("td:nth-child(4) .value").text().trim();
  95.             const da = $row.find("td:nth-child(5) .value").text().trim();
  96.             const found = $row.find("td:nth-child(6)").text().trim();
  97.  
  98.             result.push({
  99.                 index,
  100.                 pageTitle,
  101.                 pageUrl,
  102.                 anchorTitle,
  103.                 anchorUrl,
  104.                 pa,
  105.                 da,
  106.                 found,
  107.             });
  108.         });
  109.         return { result }
  110.     },
  111.  
  112.     backlink: async function (url) {
  113.         if (!url) throw Error(`param url gak boleh kosong`)
  114.         const { cookie } = await this.getCookie()
  115.         const { html } = await this.apiBackLink(url, cookie)
  116.         const { result } = this.parseHtml(html)
  117.         this.helper.log('done')
  118.         return result
  119.     }
  120. }
  121.  
  122. // cara pakai
  123. seo.backlink('https://api.paxsenix.org')
  124.     .then(console.log)
  125.     .catch(console.log)
  126.  
  127. /* output
  128. [
  129.   {
  130.     index: '1',
  131.     pageTitle: 'Sketchub • alex_',
  132.     pageUrl: 'https://web.sketchub.in/u/alex_',
  133.     anchorTitle: 'https://api.paxsenix.org/docs',
  134.     anchorUrl: 'https://api.paxsenix.org/docs',
  135.     pa: '0',
  136.     da: '32',
  137.     found: '2025-10-10'
  138.   }
  139. ]
  140. */
Tags: seo backlink
Advertisement
Add Comment
Please, Sign In to add comment