2016-05-18 11 views

答えて

0

コロナウェブビューには制限された方法があるため、これを直接行うことはできません。ただし、HTTP呼び出しを行い、データを自分で分けることができます(エディタのデータは呼び出しに付属しています)。私は通貨価格を得るためにこれを他のウェブサイトに行った。私はmoneymexウェブサイトへの呼び出しをどのようにして、私が知っているパターンに基づいて文字列を分離するかを以下に見ることができます。

secondField = display.newText("Touch to Start", 155, 155, native.systemFontBold, 16) 
secondField:setFillColor(1) 

local function networkListener(event) 
     --local alert = native.showAlert("Corona", "Crap", { "OK"}) 
    if (event.isError) then 
      local alert = native.showAlert("Corona", event.response, { "OK"}) 
    else 
    local pattern = ">%d%d,%d%d%d<" 
    local buyPrice = string.sub(event.response, string.find(event.response, pattern)) 
     -- local alert = native.showAlert("Corona", string.sub(buyPrice, 2, -2), { "OK"}) 
     local junkLength = string.len(event.response); 
     local sellJunk = string.find(event.response, pattern) 
     local sellPriceJunk= string.sub(event.response, sellJunk+50, sellJunk-junkLength+1000) 
     local sellPrice = string.sub(sellPriceJunk, string.find(sellPriceJunk, pattern)) 
secondField.text = string.sub(buyPrice,2,-2).." and "..string.sub(sellPrice,2,-2) 

    local alert = native.showAlert("Corona", string.sub(buyPrice,2,-2).." and "..string.sub(sellPrice,2,-2), { "OK"}) 

end 
end 

network.request("https://moneymex.com/Home/Welcome", "GET", networkListener) 
+0

こんにちはアミール、あなたが私に与えた応答に感謝します。あなたが与えたアイデアに関するリンクを共有すると非常に感謝します。 – Anitha

+0

ちょうどあなたのmain.luaにそれをコピーするコードを追加し、それは動作するはずです。 – Amir

関連する問題