local http = require("socket.http")
local url = require("socket.url")
local api_url = "http://api.ip.data5u.com/dynamic/get.html?order=你的提取码&sep=3"
local res, code, headers, status = http.request(api_url)
if code ~=200 then
print("获取代理IP失败:"..code)
return
end
local ip, port = string.match(res, "(.+):(.+)")
local proxy = {
proxy = {
scheme = "http",
host = ip,
port = port
}
}
local bing_url = "http://www.bing.com"
local res, code, headers, status = http.request(bing_url, proxy)
if code ~= 200 then
print("获取网页失败:"..code)
return
end
print(res) -- 打印网页源代码