lua获取喜马拉雅音频地址
参考此文http://blog.csdn.net/zjg555543/article/details/39177971
在Linux下可以直接运行
#!/usr/bin/lua5.
--需要luacurl http://luacurl.luaforge.net/
--luajson https://github.com/mbalmer/luajson
require("luacurl")
require('json') 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 function downMp3(id) local url="http://www.ximalaya.com/tracks/"..id..".json"
local mp3 = "http://fdfs.xmcdn.com/"
local ok,html = get_html(url)
if ok then
local result = json.decode(html)
print(mp3..result.play_path_64)
else
print("error")
end
end
if arg[] and tonumber(arg[]) then
downMp3(arg[])
else
print("请输入编号")
end
lua获取喜马拉雅音频地址的更多相关文章
- php实例-正则获取网站音频地址的实例(Listen to this 1)
主要用到了:file_get_contents();preg_match_all(); 这2个函数 查看地址:http://git.oschina.net/xiaoz6/phpExample
- Python爬虫实战案例:取喜马拉雅音频数据详解
前言 喜马拉雅是专业的音频分享平台,汇集了有声小说,有声读物,有声书,FM电台,儿童睡前故事,相声小品,鬼故事等数亿条音频,我最喜欢听民间故事和德云社相声集,你呢? 今天带大家爬取喜马拉雅音频数据,一 ...
- Python爬虫:爬取喜马拉雅音频数据详解
前言 喜马拉雅是专业的音频分享平台,汇集了有声小说,有声读物,有声书,FM电台,儿童睡前故事,相声小品,鬼故事等数亿条音频,我最喜欢听民间故事和德云社相声集,你呢? 今天带大家爬取喜马拉雅音频数据,一 ...
- Python爬虫|爬取喜马拉雅音频
"GOOD Python爬虫|爬取喜马拉雅音频 喜马拉雅是知名的专业的音频分享平台,用户规模突破4.8亿,汇集了有声小说,有声读物,儿童睡前故事,相声小品等数亿条音频,成为国内发展最快.规模 ...
- C#服务器获取客户端IP地址以及归属地探秘
背景:博主本是一位Windows桌面应用程序开发工程师,对网络通信一知半解.一日老婆逛完某宝,问:"为什么他们知道我的地址呢,他们是怎么获取我的地址的呢?" 顺着这个问题我们的探秘 ...
- 在Thinkphp3.2.3框架下实现自动获取客户端IP地址的get_client_ip()函数
在Thinkphp框架下使用get_client_ip()函数获取客户端IP地址十分方便: 一行代码便可以实现:$ip = get_client_ip(); 但当我们测试时会遇到后台获取的IP地址显示 ...
- Node.js、Express框架获取客户端IP地址
Node.js //传入请求HttpRequest function getClientIp(req) { return req.headers['x-forwarded-for'] || req.c ...
- 小米抢购(简单版v0.1)-登录并验证抢购权限,以及获取真实抢购地址
小米(简单版)-登录并验证抢购权限,以及获取真实抢购地址! 并不是复制到浏览器就行了的 还得传递所需要的参数 这里只是前部分 后面的自己发挥了 { "stime": 1389 ...
- C#获取真实IP地址实现方法
通常来说,大家获取用户IP地址常用的方法是: string IpAddress = ""; if((HttpContext.Current.Request.ServerVariab ...
随机推荐
- http://jingyan.baidu.com/article/7f41ecec1b7a2e593d095ce6.html
http://jingyan.baidu.com/article/7f41ecec1b7a2e593d095ce6.html http://www.linuxeden.com/html/softuse ...
- RS请求错误之RSV-BBP-0028
环境:Version Cognos10.2 单机 非集群 运行报表的时候经常遇到: 错误信息为: The secondary request failed. The requested sessio ...
- Configure Trusted Roots and Disallowed Certificates
Configure Trusted Roots and Disallowed Certificates Updated: May 5, 2014 Applies To: Windows 8.1, Wi ...
- C# 实现对微博短网址的重定向还原
新浪微博中,为了节省输入字数,通过短网址对发布微博中链接进行重定向.我们可以通过代码实现对短网址进行还原,代码如下: private string GetOrignalLink(string link ...
- STL - vector algorithm
// create vector with elements from 1 to 6 in arbitrary order vector<, , , , , }; // find and pri ...
- 通过micrometer实时监控线程池的各项指标
通过micrometer实时监控线程池的各项指标 前提 最近的一个项目中涉及到文件上传和下载,使用到JUC的线程池ThreadPoolExecutor,在生产环境中出现了某些时刻线程池满负载运作,由于 ...
- QtGui.QComboBox
The QtGui.QComboBox is a widget that allows a user to choose from a list of options. #!/usr/bin/pyth ...
- bash算术求值和errexit陷阱
原文:https://www.technovelty.org//linux/bash-arithmetic-evaluation-and-errexit-trap.html 在 "traps ...
- 【CI3.1】CI框架简单使用方法
CI框架简单使用方法 1.回忆MVC 1.1.M:模型,提供数据,保存数据 1.2.V:视图,只负责显示,表单form 1.3.C:控制器,协调模型和视图 1.4.action:动作,是控制器中的方法 ...
- centos下node.js的安装
安装的路径我举例在home目录 1.cd /home 2.下载node.js最新版本 wget http://nodejs.org/dist/v0.10.28/node-v0.10.28.tar.gz ...