Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- nama : skrinsot web
- base : https://www.screenshotmachine.com/
- by : wolep
- update : 7 November 2025, 3:17 wita (gbs tdr gw jir)
- node : v25.0.0
- note : kata web nya ada limit 100ss / bulan, gw kasih output buffer
- instead of url, karena perlu kuki buat donlot file ss
- lu bisa ubah user agent kek
- pov liat situs dari hp/table/desktop. cuma di skrep ini
- gw males bkinnya wkwkwk. liat aja payload di fungsi req.
- skrep mungkin gw update lagi kalau mood :v.
- module : esm (tested) / cjs (gak tau coba test yah :v)
- */
- import fs from 'fs'
- const ssweb = {
- _static: Object.freeze({
- baseUrl: 'https://www.screenshotmachine.com',
- baseHeaders: {
- 'content-encoding': 'zstd'
- },
- taskName: 'ssweb',
- displayLog: true,
- maxOutputLength: 200
- }),
- log: function (message) {
- if (this._static.displayLog) {
- console.log(`[${this._static.taskName}] ${message}`)
- }
- },
- pretyError: function (string) {
- if (!string) return '(empty message)'
- let message = ''
- try {
- message = JSON.stringify(string, null, 2)
- } catch (_) {
- message = string
- }
- if (message.length >= this._static.maxOutputLength) {
- message = message.substring(0, this._static.maxOutputLength) + ' [trimmed]'
- }
- return message
- },
- getCookie: async function () {
- this.log('coba ambil kuki')
- const r = await fetch(this._static.baseUrl,
- { headers: this._static.baseHeaders }
- )
- if (!r.ok) throw Error(`${r.status} ${r.statusText} at getCookie function. ${this.pretyError(await r.text())}`)
- const cookie = r.headers.getSetCookie().map(kuki => kuki.split(';')[0]).join('; ')
- if (!cookie) throw Error('gagal mendapatkan kuki')
- return { cookie }
- },
- getBuffer: async function (reqObj, cookie) {
- this.log('coba download buffer')
- if (reqObj.status !== "success") throw Error("status nya gak sukses nih objek req nyah O.o")
- const { link } = reqObj
- const api = this._static.baseUrl + '/' + link
- const r = await fetch(api, {
- headers: {
- cookie
- }
- })
- if (!r.ok) throw Error(`${r.status} ${r.statusText} at getBuffer function. ${this.pretyError(await r.text())}`)
- const ab = await r.arrayBuffer()
- const buffer = Buffer.from(ab)
- return { buffer }
- },
- req: async function (url, cookie) {
- this.log('mencoba hit server.. agak lama emang disini')
- const headers = {
- cookie,
- "content-type": "application/x-www-form-urlencoded; charset=UTF-8",
- ...this._static.baseHeaders
- }
- const path = '/capture.php'
- const r = await fetch(this._static.baseUrl + path, {
- headers,
- "body": "url=" + encodeURIComponent(url) + "&device=desktop&cacheLimit=0",
- "method": "POST"
- });
- if (!r.ok) throw Error(`${r.status} ${r.statusText} at req function. ${this.pretyError(await r.text())}`)
- const reqObj = await r.json()
- return { reqObj }
- },
- capture: async function (url) {
- if (!url) throw Error('param url gak boleh kosong')
- const { cookie } = await this.getCookie()
- const { reqObj } = await this.req(url, cookie)
- const { buffer } = await this.getBuffer(reqObj, cookie)
- this.log('all task success')
- return buffer
- }
- }
- // cara pakai
- ssweb.capture('https://alex.paxsenix.org/')
- .then(buff => {
- // handle buffer suka suka ...
- const filePath = './hasil.jpg'
- fs.writeFileSync(filePath,buff)
- console.log('ss web di simpan di ' + filePath)
- })
- .catch(error => {
- console.log('skrep gagal!' + error.message)
- })
- /* log output
- [ssweb] coba ambil kuki
- [ssweb] mencoba hit server.. agak lama emang disini
- [ssweb] coba download buffer
- [ssweb] all task success
- ss web di simpan di ./hasil.jpg
- */
Advertisement
Add Comment
Please, Sign In to add comment