Lua腳本獲取喜馬拉雅MP3音頻地址
來源:易賢網(wǎng) 閱讀:1459 次 日期:2015-04-24 10:42:16
溫馨提示:易賢網(wǎng)小編為您整理了“Lua腳本獲取喜馬拉雅MP3音頻地址”,方便廣大網(wǎng)友查閱!

下面介紹了Lua腳本獲取喜馬拉雅MP3音頻地址,本文直接給出代碼實(shí)例,需要的朋友可以參考下

  在Linux下可以直接運(yùn)行

#!/usr/bin/lua5.1

--需要luacurl

--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函數(shù),必須有

table.insert(tab, buffer) --tab參數(shù)即為result,參考

return #buffer

end)

local ok = c:perform()

return ok, table.concat(result) --此table非上一個table,作用域不同

end

function downMp3(id)

local url=""

local mp3 = ""

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[1] and tonumber(arg[1]) then

downMp3(arg[1])

else

print("請輸入編號")

end

更多信息請查看IT技術(shù)專欄

更多信息請查看網(wǎng)絡(luò)編程
易賢網(wǎng)手機(jī)網(wǎng)站地址:Lua腳本獲取喜馬拉雅MP3音頻地址
由于各方面情況的不斷調(diào)整與變化,易賢網(wǎng)提供的所有考試信息和咨詢回復(fù)僅供參考,敬請考生以權(quán)威部門公布的正式信息和咨詢?yōu)闇?zhǔn)!
關(guān)于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機(jī)站點(diǎn)

版權(quán)所有:易賢網(wǎng)