LuaCURL:http://luacurl.luaforge.net/

curl大家应该都知道吧,在linux下被广泛使用,也有windows版本,网络上还有其win32版本的源代码。它是一个命令行工具,用它可以实现向服务器发送一些协议包。以前在入侵一些安全性比较差的网站,都会使用到它,来向HTTP服务器发送自己构造的数据包。现在这个curl也有了lua版本,可以去下载luacurl.dll 是开源的。下面看一个例子利用它获取百度首页html源码。

curl = require("luacurl")

function get_html(url, c)
local result = { }
if c == nil then
c = curl.new()
end
c:setopt(curl.OPT_URL, url)
c:setopt(curl.OPT_WRITEDATA, result)
c:setopt(curl.OPT_WRITEFUNCTION, function(tab, buffer) --call back函数,必须有
table.insert(tab, buffer) --tab参数即为result,参考http://luacurl.luaforge.net/ return #buffer
end)
local ok = c:perform()
return ok, table.concat(result) --此table非上一个table,作用域不同
end ok, html = get_html("http://www.baidu.com/")
if ok then
print (html) else print ("Error" )
end

转自:http://www.cnblogs.com/daxingxing/archive/2011/08/30/2159732.html

======================================

LuaCURL 源码可以在 Lua Forge 页面下载(LuaCurl 1.0 绑定 CURL 7.14.0).

LuaCURL的更多相关文章

  1. 关于Cookies与Session系列一

    这两个东西,最近项目操作的比较少,不过这两个在Web项目开发中一直都扮演着很重要的角色,有时有些细节会不小心就遗忘掉. Cookies  的概述 Cookies是由服务器端生成,发送给客户端,用来保存 ...

  2. lua cURL使用笔记

    cURL cURL是 URL命令行工具, 即 command URL, 可以通过命令行模拟各种应用协议的发包, 包括FTP HTTP HTTPS, 官方网站 http://curl.haxx.se/ ...

  3. lua curl动态链接库编译安装(二)

    下面再介绍一下lua-curl中的lua-curl-0.2.tar.gz版本的安装方法,可能对于一般的人来说这个很简单,但是对于我们这些菜鸟来说就不一样了: # wget http://files.l ...

  4. lua curl动态链接库编译安装

    关于lua curl的资料网上并不是很多.找来找去就那么几个,所以我绝得很有必要把我的经验记下来,以防下次忘记                                              ...

  5. lua接收图片并进行md5处理

    需要luacurl(http://luacurl.luaforge.net/)和MD5两个库函数 curl = require("luacurl") require("m ...

  6. luarocks模块管理工具

    1.简介 该软件包可以安装和更新lua的第三方模块. 2.下载地址 请在 http://luarocks.org/releases/ 页面选择需要的软件包. wget http://luarocks. ...

  7. Lua的各种资源1

    Libraries And Bindings     LuaDirectory > LuaAddons > LibrariesAndBindings This is a list of l ...

  8. lua获取喜马拉雅音频地址

    参考此文http://blog.csdn.net/zjg555543/article/details/39177971 在Linux下可以直接运行 #!/usr/bin/lua5. --需要luacu ...

  9. 解决openresty http客户端不支持https的问题

    OpenResty默认没有提供Http客户端,需要使用第三方提供:当然我们可以通过ngx.location.capture 去方式实现,但它只能发送一个子请求. 第三方基本是以lua-resty-ht ...

随机推荐

  1. [POJ1082]Calendar Game

    题目大意: 日历上博弈,从给定的日期,按照下述规则跳转日期: 1.跳到第二天: 2.调到下个月相同的日期(如果没有就不能跳转). 刚刚好跳到2001年11月4日的人胜,跳转时不能跳到2001年11月4 ...

  2. hdu 4417 区间内比h小的数 线段树

    题意求区间内比h小的数的个数 将所有的询问离线读入之后,按H从小到大排序.然后对于所有的结点也按从小到大排序,然后根据查询的H,将比H小的点加入到线段树,然后就是一个区间和. 2015-07-27:专 ...

  3. Codeforces Round #222 (Div. 1) C. Captains Mode 状压

    C. Captains Mode 题目连接: http://codeforces.com/contest/377/problem/C Description Kostya is a progamer ...

  4. Codeforces Round #254 (Div. 1) C. DZY Loves Colors 分块

    C. DZY Loves Colors 题目连接: http://codeforces.com/contest/444/problem/C Description DZY loves colors, ...

  5. Codeforces Round #257 (Div. 2) A. Jzzhu and Children

    A. Jzzhu and Children time limit per test 1 second memory limit per test 256 megabytes input standar ...

  6. Xcode更新后插件失效解决办法

    defaults read /Applications/Xcode.app/Contents/Info DVTPlugInCompatibilityUUID 获取新版xcode的uuid Xcode6 ...

  7. GIT(3)----问题汇总

    1.git pull出现的合并问题: Please enter a commit message to explain why this merge is necessary,especially i ...

  8. 【原】MyBatis执行DDL:create table,drop table等等

    [前言] 对MyBatis一直停留在仅仅会用的阶段,常用的场景就是通过MyBatis对表数据进行DML(insert, delete, update等)操作,从来没有想过通过MyBatis对数据库 进 ...

  9. 关于maven依赖中的<scope>provided</scope>使用

    今天开发web的时候,需要用到servlet-api,于是在pom.xml中添加依赖 <dependency> <groupId>javax.servlet</group ...

  10. Save a 32-bit Bitmap as 1-bit .bmp file in C#

    What is the easiest way to convert and save a 32-bit Bitmap to a 1-bit (black/white) .bmp file in C# ...