Lua-cURL: https get into string

我想使用lcURL将HTTPS响应的正文获取到Lua变量中。这是我目前的代码,但它不起作用:

local cURL = require("lcurl");

function x(str)
    print(x)
end

curl = cURL.easy{url='https://devrant.com', writefunction=x}:perform():close()

我找到了很多将它们写入文件的示例,但没有写入变量的示例。

我的输出是:

function: 0x5594bfd310f0
function: 0x5594bfd310f0
点赞
用户8062151
用户8062151

我发誓我不是个白痴,但是我在这篇帖子中的行为明显是相反的证据。我正在打印 x。天哪。解决办法是打印 str

2019-12-24 04:36:42