在lua中使用cURL [英] using cURL in lua
本文介绍了在lua中使用cURL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试在一些lua脚本中使用curl库.
I am trying to use the curl library in a little lua script.
我知道有一个"-k"选项可禁用默认情况下curl进行的证书验证...但是我无法通过代码找到如何做到这一点.
I know there is a "-k" option to disable the certification verification that curl does by default... but I haven't been able to find how to do it via code.
这是我到目前为止的内容:
here's what I have so far:
local cURL = require("cURL")
headers = {"Accept: text/*",
"Accept-Language: en",
"Accept-Charset: iso-8859-1,*,utf-8",
"Cache-Control: no-cache"}
login_url = "https://10.10.2.1/cgi-bin/acd/myapp/controller/method?userid=tester&password=123123"
c = cURL.easy_init()
c:setopt_url(login_url)
c:perform({writefunction=function(str)
succeed = succeed or (string.find(str, "srcId:%s+SignInAlertSupressor--"))
end })
感谢您的宝贵时间.
推荐答案
使用新版本的Lua-cURL [1],您可以编写
With new version of Lua-cURL[1] you can write
local cURL = require("cURL")
headers = {
"Accept: text/*",
"Accept-Language: en",
"Accept-Charset: iso-8859-1,*,utf-8",
"Cache-Control: no-cache"
}
login_url = "https://10.10.2.1/cgi-bin/acd/myapp/controller/method?userid=tester&password=123123"
c = cURL.easy{
url = login_url,
ssl_verifypeer = false,
ssl_verifyhost = false,
httpheader = headers,
writefunction = function(str)
succeed = succeed or (string.find(str, "srcId:%s+SignInAlertSupressor--"))
end
}
c:perform()
1- https://github.com/Lua-cURL/Lua-cURLv3
这篇关于在lua中使用cURL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文