local D=require("\064\108\117\110\101\047\112\114\111\099\101\115\115")local r=require("\064\108\117\110\101\047\102\115")local K=require("\046\046\047\115\114\099")local e=assert(D.args[1],"\077\117\115\116 \112\114\111\118\105\100\101 \119\101\098\115\111\099\107\101\116 \117\114\108")local Y=assert(D.args[2],"\077\117\115\116 \112\114\111\118\105\100\101 \112\097\116\104\047\116\111\047\102\105\108\101\047\105\110\100\101\120\046\104\116\109\108")local A=K.Browser.connect(e)local i=A:new_tab()local x=((i:navigate_to("\104\116\116\112\115\058\047\047\119\119\119\046\119\105\107\105\112\101\100\105\097\046\111\114\103")):wait_until_navigated()):print_to_pdf()r.writeFile("\119\105\107\105\046\112\100\102",x)print("\080\068\070 \115\117\099\099\101\115\115\102\117\108\108\121 \099\114\101\097\116\101\100 \102\114\111\109 \105\110\116\101\114\110\101\116 \119\101\098 \112\097\103\101\046")local V=((i:navigate_to(Y)):wait_until_navigated()):print_to_pdf()r.writeFile("\114\117\115\116\046\112\100\102",V)print("\080\068\070 \115\117\099\099\101\115\115\102\117\108\108\121 \099\114\101\097\116\101\100 \102\114\111\109 \108\111\099\097\108 \119\101\098 \112\097\103\101\046")
local process = require("@lune/process")
local fs = require("@lune/fs")
local chrome = require("../src")

local WEBSOCKET_URL = assert(process.args[1], "Must provide websocket url")
local FILE_PATH = assert(process.args[2], "Must provide path/to/file/index.html")

local browser = chrome.Browser.connect(WEBSOCKET_URL)
local tab = browser:new_tab()

local wikidata = tab:navigate_to("https://www.wikipedia.org"):wait_until_navigated():print_to_pdf()
fs.writeFile("wiki.pdf", wikidata)
print("PDF successfully created from internet web page.")

local local_pdf = tab:navigate_to(FILE_PATH):wait_until_navigated():print_to_pdf()
fs.writeFile("rust.pdf", local_pdf)
print("PDF successfully created from local web page.")
