惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

P
Privacy & Cybersecurity Law Blog
Vercel News
Vercel News
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
N
Netflix TechBlog - Medium
罗磊的独立博客
F
Fortinet All Blogs
T
Threatpost
Y
Y Combinator Blog
博客园_首页
美团技术团队
Security Latest
Security Latest
博客园 - 三生石上(FineUI控件)
T
Tailwind CSS Blog
V
V2EX - 技术
The Cloudflare Blog
L
LINUX DO - 热门话题
博客园 - 司徒正美
Jina AI
Jina AI
P
Proofpoint News Feed
宝玉的分享
宝玉的分享
C
CXSECURITY Database RSS Feed - CXSecurity.com
C
Cybersecurity and Infrastructure Security Agency CISA
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
WordPress大学
WordPress大学
The Hacker News
The Hacker News
P
Privacy International News Feed
T
The Exploit Database - CXSecurity.com
Scott Helme
Scott Helme
有赞技术团队
有赞技术团队
V
V2EX
Stack Overflow Blog
Stack Overflow Blog
M
MIT News - Artificial intelligence
Latest news
Latest news
NISL@THU
NISL@THU
Google DeepMind News
Google DeepMind News
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
C
Cisco Blogs
雷峰网
雷峰网
Application and Cybersecurity Blog
Application and Cybersecurity Blog
B
Blog RSS Feed
W
WeLiveSecurity
D
DataBreaches.Net
G
Google Developers Blog
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
G
GRAHAM CLULEY
Spread Privacy
Spread Privacy
Know Your Adversary
Know Your Adversary
TaoSecurity Blog
TaoSecurity Blog
S
Securelist
Help Net Security
Help Net Security

博客园 - Jaypei

archlinux中启用sshd [转] AT89C52资料 VirtualBox中安装PuppyLinux4 [转]比较全的Vim 中的正则表达式 [转]使用Mac OS X系统必须了解的10条命令 [原]Qt4.5中Plugins使用方法 用nuSOAP传递对象数组的问题终于解决 粗心导致的gsoap一个错误 MinGW环境使用gSOAP rdesktop中剪切板共享 - Jaypei [转]在Windows XP下用GCC 4.3.2编译Qt 4.4.3实战 - Jaypei Ubuntu下安装Postgresql 8.3 - Jaypei [原创]关于python的Singleton - Jaypei [转]如何讀取文字檔? (C/C++) (STL) 简单的python读写windows剪切板 - Jaypei 关于SOAPpy传递对象参数调用WebService的问题总结 - Jaypei LinkedServer的用法 - Jaypei 解决Smarty中trancate使用UTF8时中文乱码问题 - Jaypei 关于wxPython中多线程修改主界面 - Jaypei
luacurl的一个获得html的函数
Jaypei · 2009-07-16 · via 博客园 - Jaypei

2009-07-16 17:49  Jaypei  阅读(2466)  评论()    收藏  举报

盖碗茶大哥的建议下,开始学习lua,看完了lua的基础,该写点东西练练手了。

是一个简单的get方法获取html的函数,发现luacurl的文档讲的很简单,还好有一个example。

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)
        
table.insert(tab, buffer)
        
return #buffer
    
end)
    
local ok = c:perform()
    
return ok, table.concat(result)
end

ok, html 

= get_html("http://jaypei.cnblogs.com/")
if ok then
    
print (html)
end