[ 登录 ] - [ 注册 ] | 免费代理IP 数据无忧_无忧代理IP_DATA5U最新上线 | 代码示例DEMO | IP测试视频 | 用户协议
Lua代码调用示例


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) -- 打印网页源代码


微信公众号
关注微信公众号