file=io.open("/storage/emulated/0/by—FH.MyCity","r") if file~=nil then con=file:read("*a") dz=con:match("%&(.-)%&") city=con:match("@(.-)@") file:close() else city=gg.prompt({"输入城市"},{""},{"text"})[1] local function Enc(Mzsh) return Mzsh:gsub(".", function(jia) return string.format("%%%02X", (string.byte(jia)) % 256) end):gsub(" ", "+") end dz=string.match(gg.makeRequest("http://toy1.weather.com.cn/search?cityname="..Enc(city).."&callback=success_jsonpCallback&_=1532937966722").content,"ref\":\"(.-)~") if dz==nil then gg.alert("输入错误城市,请重新输入") os.exit() else f=io.open("/storage/emulated/0/.MyCity","w"):write("@"..city.."@\n&"..dz.."&"):close() end end function split(s, p) local rt = {} string.gsub(s,"[^" .. p .. "]+",function(w) table.insert(rt, w) end ) return rt end function x(x) local i=0 for w in string.gmatch(x,"active") do i=i+1 end local t=string.rep("⭐",i) return t end ------- tq=gg.makeRequest("http://www.weather.com.cn/weather1d/"..dz..".shtml").content ---获取1天内天气 a=string.gsub(string.gsub(string.gsub(string.gsub(string.match(tq,"var hour3data={\"1d\":%[(.-)]"),"\",\"","$$"),"\"",""),",...,",","),",(%d+)%$","") b=split(a,"$")--天气 ---获取生活指数 tab={"

(.-)

","(.-)","\n\n","
(.-)
"} shzs=gg.makeRequest("http://www.weather.com.cn/weather1dn/"..dz..".shtml").content tq1=string.match(shzs,"生活助手(.-)") c={} for i=1,4 do c[i]={} for w in string.gmatch(tq1,tab[i]) do if i==1 then if string.find(w,"em") then w="健臻·血糖" end end table.insert(c[i],w) end end ts={} for v=1,6 do ts[v]={} for i=1,4 do table.insert(ts[v],c[i][v]) end end mm="" for i=1,6 do mm=mm..ts[i][1]..":"..ts[i][2].."\n指数:"..x(ts[i][3]).."\n温馨提示:"..ts[i][4].."\n\n" end gg.alert("当前城市:"..city.."\n"..table.concat(b,"\n").."\n-----------\n".."生活助手:\n"..mm)