Lua 代码解析网页 Cookie 获取 token 和 userId 并显示
该代码段是 Lua 语言的一段代码,功能是用于解析网页 Cookie 中的 token 和 userId,并将其拼接成一个新的 Cookie 字符串,最后在 Android 应用中显示该字符串。
具体实现过程是,首先判断 webcookie 中是否包含'token=',如果包含则使用 Lua 的字符串匹配函数获取 token 和 userId 的值,并将其拼接成一个新的 Cookie 字符串;然后将该字符串设置为文本的内容,并将其显示在控件上。如果 webcookie 中不包含'token=',则不执行任何操作。
if(webcookie:find'token=') then
token='token='..webcookie:match('token=(.-);')
userId='userId='..webcookie:match('userId=(.-);')
cookie=userId..'&'..token
mycookietxt.setText(cookie)--设置文本内容
cookielay.setVisibility(View.VISIBLE)--显示控件
end
原文地址: https://www.cveoy.top/t/topic/m889 著作权归作者所有。请勿转载和采集!