INT 21h

Hi, I am Vladimir Smagin, SysAdmin and Kaptain. Telegram Email / GIT / RSS / GPG

Splash: how to change user-agent with Lua in Bash

№ 10157 В разделах: Programming Sysadmin от August 3rd, 2019,
В подшивках: , , ,

Before start install jq application, required to work with JSON, used to prepare lua script for sending to Splash API.

Create file named splash.lua

function main(splash, args)
  splash:set_user_agent('Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_2_1 like Mac OS X; en-us) AppleWebKit/525.18.1 (KHTML, like Gecko) Version/3.1.1 Mobile/5H11 Safari/525.20')
  splash:set_viewport_size(800, 600)
  return splash:png()

Create bash script


JSON="{\"lua_source\":$(jq -Rs . < script.lua)}"

curl -s -X POST -H "Content-Type: application/json" -d "${JSON}" \
   "" -o out.png

Check result image

Нет комментариев »

Leave a Reply

Your email address will not be published. Required fields are marked *


Облачная платформа

Fortune cookie: Today's spam: Take this and be d;ck almighty