首先,你需要安装一个 Lua 的爬虫库,例如 Luanode 或者 Lush:
```lua
local ltn12 = require("ltn12")
local http = require("")
local response = http.request{
host = "",
port = ,
path = "/",
use_proxy = true,
proxy_host = "",
proxy_port = ,
headers = { ["User-Agent"] = "Luanode" },
body = "",
}
local reader = ltn12.reader.response(response)
local writer = ltn12.writer.buffer
local _, err = require("socket").connect(response.proxied_host, response.proxied_port)
if not err then
for chunk in reader:chunk() do
print(chunk)
end
end
```
在这个示例中,我们首先导入了 Luanode 和 socket.http 库。然后,我们创建了一个 HTTP 请求,设置了代理信息,并设置了请求头。然后,我们使用 Luanode 的 http.request 函数发送请求。