《2018年8月8日》【连续310天】
标题:splash lua脚本,API调用;
内容:
1.lua脚本:
function main(splash)
return "hello world"
end
lua脚本语言的基本语法:
http://www.runoob.com/lua/lua-basic-syntax.html
2.API调用:
脚本:
function main(splash)
local treat =require("treat")
local response =splash:http_get("http://httpbin.org/get")
local results ={}
return {
html=treat.as_string(response.body),
url=response.url,
status =response.status
}
end
通过python调用:
import requests
from urllib.parse import quote
f=open("lua.lua")
lua =f.read()
url="http://**.**.**.**:8050/execute?lua_source="+quote(lua)
response =requests.get(url)
print(response.text)