--安卓发小红书
local function trimRN(str) --linux 上去除\r换行符,读取问题多是有符号和空格的原因
if str == nil then
return nil,"the string parameter is nil"
end
-- str = string.gsub(str, " ", "")
str = string.gsub(str,"\r","")
str = string.gsub(str,"\n","")
return str
end
function movefile(path,to)--帮你玩平台禁用此函数
os.execute("mv "..path.." "..to);
end
function click(x, y,ms)
local x,y=math.random(x,x+5),math.random(y-5,y)
touchDown(0, x, y)
mSleep(50)
touchUp(0, x, y)
if ms then mSleep(ms) else mSleep(50) end
end
function getList(path)--getList 遍历文件
local a = io.popen("ls "..path);
local f = {};
for l in a:lines() do
table.insert(f,l)
end
return f
end
function findFile(path)
local a = io.popen("find "..path.." -prune");
local f = {};
for l in a:lines() do
table.insert(f,l)
end
a:close()
return f
end
function serialize(obj)
local lua = ""
local t = type(obj)
if t == "number" then
lua = lua .. obj
elseif t == "boolean" then
lua = lua .. tostring(obj)
elseif t == "string" then
lua = lua .. string.format("%q", obj)
elseif t == "table" then
lua = lua .. "{\n"
for k, v in pairs(obj) do
lua = lua .. "[" .. serialize(k) .. "]=" .. serialize(v) .. ",\n"
end
local metatable = getmetatable(obj)
if metatable ~= nil and type(metatable.__index) == "table" then
for k, v in pairs(metatable.__index) do
lua = lua .. "[" .. serialize(k) .. "]=" .. serialize(v) .. ",\n"
end
end
lua = lua .. "}"
elseif t == "nil" then
return nil
else
error("can not serialize a " .. t .. " type.")
end
return lua
end
function unserialize(lua)
local t = type(lua)
if t == "nil" or lua == "" then
return nil
elseif t == "number" or t == "string" or t == "boolean" then
lua = tostring(lua)
else
error("can not unserialize a " .. t .. " type.")
end
lua = "return " .. lua
local func = loadstring(lua)
if func == nil then
return nil
end
return func()
end
function login(zuobiao,wenzi,ms)
cik(zuobiao)
shuru(wenzi)
mSleep(ms)
end
function fengexy(axz)--分割x,y轴
return string.match(axz, "[^%d]([%d-]*)[^%d]([%d]*)[^%d]*([%d]*)[^%d]([%d]*)")
end
function cik(dianji)
local x1,y1,x2,y2 = fengexy(dianji)
local xx = math.random(x1+5,x2-5)--缩小10个像素
local yy = math.random(y1+5,y2-5)--缩小10个像素
click(xx,yy,1000)
end
function ReadFile(path, isdel)-- 读取文件 [path:路径, isdel:是否删除] [返回文件内容, 失败返回空字符串]
local iRet, sRet = pcall(function()
local f = io.open(path, "r")
if f == null then
return ""
end
local ret = f:read("*all")
f:close()
if isdel then
os.remove(path)
end
return ret
end)
if iRet == true then
return sRet
else
return ""
end
end
function JsCmd(m)
local tmp
CMDAPK=userPath().."/res/JsAndroid.apk"
if(m==1)then
os.execute(string.format("nohup app_process -Djava.class.path=%s / com.jsdroid.core.JsMain &",CMDAPK))
elseif(m==2)then
os.execute(string.format("app_process -Djava.class.path=%s / com.jsdroid.core.JsMain",CMDAPK))
end
end
function Code(code)
local chaoshi=1
repeat
status_resp, header_resp,body_resp = ts.httpGet("http://127.0.0.1:9800?js="..code)
if body_resp then
zfdafd = true
if status_resp==200 and body_resp~=nil and string.len(body_resp)>1 then
break;
end
else
if status_resp==0 and header_resp~=nil and string.len(header_resp)>1 then
break;
end
end
chaoshi=chaoshi+1
mSleep(20)
if chaoshi>50 then
do return "sb" end
break;
end
until (false)
if zfdafd then
return body_resp
else
return header_resp
end
end
function IsStart(time)
local out = os.time() + time
local tmp
while(os.time()<out)do
tmp=Code("'start'")
if tmp=="start" then
do return true end
else
toast("mei-qi-dong",1)
end
mSleep(1000)
end
return false
end
function StartService(...)
JsCmd(1)
if IsStart(3)==false then
toast("方式一启动失败,尝试使用方式二")
-- mSleep(2000)
JsCmd(2)
if IsStart(3)==false then
-- dialog("启动服务失败!",0)
-- mSleep(2000)
-- lua_exit()
end
end
end
function GetUIXml()--获取XML文件
StartService()
return Code("getXml()")
end
function XmlToTable(xml)-- XML转Table
local iRet, sRet = pcall(function()
local tXml = {}
local i = 1
for k in xml:gmatch("<node[^>]+/?>") do
tXml[i] = {}
for w, y in k:gmatch("([a-zA-Z-]+)=\"([^\"]+)\"") do
tXml[i][w] = y
end
i = i + 1
end
return tXml
end)
if iRet == true then
return sRet
else
return ""
end
end
function FindXmlKeyA(Xml, key, val, key1)
local iRet, sRet = pcall(function()
local tXml = XmlToTable(Xml)
local tmptable = {}
for i = 1, #tXml do
if tXml[i][key] == val then
--table.insert(tmptable, tXml[i][key1]:match("\"(.+)\""))
--4-16修改 附近人表情昵称,不识别
table.insert(tmptable, tXml[i][key1])
end
end
if tmptable[1] == nil then
return nil
else
return tmptable
end
end)
if iRet == true then
return sRet
else
print(sRet)
return nil
end
end
function FindXmlKeyA_1(Xml, key, val,key_1, val_1,key1)
local iRet, sRet = pcall(function()
local tXml = XmlToTable(Xml)
local tmptable = {}
for i = 1, #tXml do
if tXml[i][key] == val and tXml[i][key_1] == val_1 then
--table.insert(tmptable, tXml[i][key1]:match("\"(.+)\""))
--4-16修改 附近人表情昵称,不识别
table.insert(tmptable, tXml[i][key1])
end
end
if tmptable[1] == nil then
return nil
else
return tmptable
end
end)
if iRet == true then
return sRet
else
print(sRet)
return nil
end
end
function FindXmlKey(Xml, key, val, key1)-- 查找XML字符串 [返回第一个查找到的字符串]
local iRet, sRet = pcall(function()
local tXml = XmlToTable(Xml)
local i = 1
for i = 1, #tXml do
if tXml[i][key] == val then
return tXml[i][key1]
end
end
return nil
end)
if iRet == true then
return sRet
else
return nil
end
end
function chengxu(cx,ms)
while true do
r = runApp(cx);
mSleep(ms); --启动应用
if r == 0 then
if frontAppBid() == cx then
break
end
end
end
end
function shuru(wenzix)
local strt={}
for ch in string.gmatch(wenzix,"[\0-\x7f\xc2-\xf4][\x80-\xbf]*") do
table.insert(strt,ch)
end
toast("开始输入"..#strt.."个字",5)
for k,v in pairs(strt) do
inputText(v) --逐字输入
mSleep(math.random(500,800))
end
end
function rndLetter(num)--随机大小写
local ret = ""
pcall(function()
for var = 1,num do
if math.random()>0.5 then
ret = ret..string.char(math.random(65,90))
else
ret = ret..string.char(math.random(97,122))
end
end
end)
return ret
end
require "TSLib"
ts = require("ts")
--unlockDevice(); --解锁屏幕
--setBacklightLevel(0);setVolumeLevel(0)
ts_enterprise_lib = require("ts_enterprise_lib")
assert(ts_enterprise_lib,"无法引入企业专用库")
local category = "小红书作品链接"
math.randomseed(tostring(ts.ms()):reverse():sub(1, 6))
flag = deviceIsLock(); --判断屏幕是否锁定
if flag == 0 then
else
unlockDevice(); --解锁屏幕
end--开机自启动请勿使用此段代码,直接使用 unlockDevice 函数即可
closeApp("com.xingin.xhs")---关闭小红书
mSleep(1000)
for i=1,1000 do
local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","get_data",category)
if ok then
if ret1 then
openURL(ret2);
mSleep(1000)
for var= 1, 100 do
mSleep(100)
local glc = GetUIXml()
-- local fia3 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/yv","bounds")--关注数量
local fia4 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/likeLayout","bounds")--点赞
local fia3 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/yy","bounds")--关注
local dz_1 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/aat","text")--点赞数量
local dz_2 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/likeTextView","text")--点赞数量
local dz452 = FindXmlKey(glc,"text","添加评论…","class")--点赞数量
if fia3 or dz_1 or dz_2 or dz452 then
mSleep(1000)
if not fia4 then
touch():Step(50)n(200,1000):move(200,200)ff()
touch():Step(50)n(200,1000):move(200,200)ff()
end
mSleep(500)
local glc = GetUIXml()
local dz_1 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/aat","text")--点赞数量
local dz_2 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/likeTextView","text")--点赞数量
if dz_1 then
dz = dz_1
elseif dz_2 then
dz = dz_2
end
local sc_1 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/nw","text")--收藏数量
local sc_2 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/nz","text")--收藏数量
if sc_1 then
sc = sc_1
elseif sc_2 then
sc = sc_2
end
local pl_1 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/o7","text")--评论数量
local pl_2 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/commentTextView","text")--评论数量
if pl_1 then
pl = pl_1
elseif pl_2 then
pl = pl_2
end
local shijian = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/b0p","text")--发布时间
local data = {dz=dz,sc=sc,pl=pl,lianjie=ret2,shijian=shijian} --需要写入的数据
for var= 1, 10 do
local ok,err = ts_enterprise_lib:cloud_db_add('5d0be2726ce6ba000cc091d0',data,30)
if ok then
break
end
end
-- dialog("完成", time)
dz,sc,pl = nil
break
end
if FindXmlKey(glc,"text","等待","bounds") then
cik(FindXmlKey(glc,"text","等待","bounds"))
end
if var == 100 then
for i=1,10 do
local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","revert_data",category,ret2)
if ok and ret1 then
break
end
end
-- lua_exit(); --否则退出脚本
-- os.execute("reboot");
end
end
os.execute("input keyevent KEYCODE_BACK")
end
end
end--安卓发小红书
local function trimRN(str) --linux 上去除\r换行符,读取问题多是有符号和空格的原因
if str == nil then
return nil,"the string parameter is nil"
end
-- str = string.gsub(str, " ", "")
str = string.gsub(str,"\r","")
str = string.gsub(str,"\n","")
return str
end
function movefile(path,to)--帮你玩平台禁用此函数
os.execute("mv "..path.." "..to);
end
function click(x, y,ms)
local x,y=math.random(x,x+5),math.random(y-5,y)
touchDown(0, x, y)
mSleep(50)
touchUp(0, x, y)
if ms then mSleep(ms) else mSleep(50) end
end
function getList(path)--getList 遍历文件
local a = io.popen("ls "..path);
local f = {};
for l in a:lines() do
table.insert(f,l)
end
return f
end
function findFile(path)
local a = io.popen("find "..path.." -prune");
local f = {};
for l in a:lines() do
table.insert(f,l)
end
a:close()
return f
end
function serialize(obj)
local lua = ""
local t = type(obj)
if t == "number" then
lua = lua .. obj
elseif t == "boolean" then
lua = lua .. tostring(obj)
elseif t == "string" then
lua = lua .. string.format("%q", obj)
elseif t == "table" then
lua = lua .. "{\n"
for k, v in pairs(obj) do
lua = lua .. "[" .. serialize(k) .. "]=" .. serialize(v) .. ",\n"
end
local metatable = getmetatable(obj)
if metatable ~= nil and type(metatable.__index) == "table" then
for k, v in pairs(metatable.__index) do
lua = lua .. "[" .. serialize(k) .. "]=" .. serialize(v) .. ",\n"
end
end
lua = lua .. "}"
elseif t == "nil" then
return nil
else
error("can not serialize a " .. t .. " type.")
end
return lua
end
function unserialize(lua)
local t = type(lua)
if t == "nil" or lua == "" then
return nil
elseif t == "number" or t == "string" or t == "boolean" then
lua = tostring(lua)
else
error("can not unserialize a " .. t .. " type.")
end
lua = "return " .. lua
local func = loadstring(lua)
if func == nil then
return nil
end
return func()
end
function login(zuobiao,wenzi,ms)
cik(zuobiao)
shuru(wenzi)
mSleep(ms)
end
function fengexy(axz)--分割x,y轴
return string.match(axz, "[^%d]([%d-]*)[^%d]([%d]*)[^%d]*([%d]*)[^%d]([%d]*)")
end
function cik(dianji)
local x1,y1,x2,y2 = fengexy(dianji)
local xx = math.random(x1+5,x2-5)--缩小10个像素
local yy = math.random(y1+5,y2-5)--缩小10个像素
click(xx,yy,1000)
end
function ReadFile(path, isdel)-- 读取文件 [path:路径, isdel:是否删除] [返回文件内容, 失败返回空字符串]
local iRet, sRet = pcall(function()
local f = io.open(path, "r")
if f == null then
return ""
end
local ret = f:read("*all")
f:close()
if isdel then
os.remove(path)
end
return ret
end)
if iRet == true then
return sRet
else
return ""
end
end
function JsCmd(m)
local tmp
CMDAPK=userPath().."/res/JsAndroid.apk"
if(m==1)then
os.execute(string.format("nohup app_process -Djava.class.path=%s / com.jsdroid.core.JsMain &",CMDAPK))
elseif(m==2)then
os.execute(string.format("app_process -Djava.class.path=%s / com.jsdroid.core.JsMain",CMDAPK))
end
end
function Code(code)
local chaoshi=1
repeat
status_resp, header_resp,body_resp = ts.httpGet("http://127.0.0.1:9800?js="..code)
if body_resp then
zfdafd = true
if status_resp==200 and body_resp~=nil and string.len(body_resp)>1 then
break;
end
else
if status_resp==0 and header_resp~=nil and string.len(header_resp)>1 then
break;
end
end
chaoshi=chaoshi+1
mSleep(20)
if chaoshi>50 then
do return "sb" end
break;
end
until (false)
if zfdafd then
return body_resp
else
return header_resp
end
end
function IsStart(time)
local out = os.time() + time
local tmp
while(os.time()<out)do
tmp=Code("'start'")
if tmp=="start" then
do return true end
else
toast("mei-qi-dong",1)
end
mSleep(1000)
end
return false
end
function StartService(...)
JsCmd(1)
if IsStart(3)==false then
toast("方式一启动失败,尝试使用方式二")
-- mSleep(2000)
JsCmd(2)
if IsStart(3)==false then
-- dialog("启动服务失败!",0)
-- mSleep(2000)
-- lua_exit()
end
end
end
function GetUIXml()--获取XML文件
StartService()
return Code("getXml()")
end
function XmlToTable(xml)-- XML转Table
local iRet, sRet = pcall(function()
local tXml = {}
local i = 1
for k in xml:gmatch("<node[^>]+/?>") do
tXml[i] = {}
for w, y in k:gmatch("([a-zA-Z-]+)=\"([^\"]+)\"") do
tXml[i][w] = y
end
i = i + 1
end
return tXml
end)
if iRet == true then
return sRet
else
return ""
end
end
function FindXmlKeyA(Xml, key, val, key1)
local iRet, sRet = pcall(function()
local tXml = XmlToTable(Xml)
local tmptable = {}
for i = 1, #tXml do
if tXml[i][key] == val then
--table.insert(tmptable, tXml[i][key1]:match("\"(.+)\""))
--4-16修改 附近人表情昵称,不识别
table.insert(tmptable, tXml[i][key1])
end
end
if tmptable[1] == nil then
return nil
else
return tmptable
end
end)
if iRet == true then
return sRet
else
print(sRet)
return nil
end
end
function FindXmlKeyA_1(Xml, key, val,key_1, val_1,key1)
local iRet, sRet = pcall(function()
local tXml = XmlToTable(Xml)
local tmptable = {}
for i = 1, #tXml do
if tXml[i][key] == val and tXml[i][key_1] == val_1 then
--table.insert(tmptable, tXml[i][key1]:match("\"(.+)\""))
--4-16修改 附近人表情昵称,不识别
table.insert(tmptable, tXml[i][key1])
end
end
if tmptable[1] == nil then
return nil
else
return tmptable
end
end)
if iRet == true then
return sRet
else
print(sRet)
return nil
end
end
function FindXmlKey(Xml, key, val, key1)-- 查找XML字符串 [返回第一个查找到的字符串]
local iRet, sRet = pcall(function()
local tXml = XmlToTable(Xml)
local i = 1
for i = 1, #tXml do
if tXml[i][key] == val then
return tXml[i][key1]
end
end
return nil
end)
if iRet == true then
return sRet
else
return nil
end
end
function chengxu(cx,ms)
while true do
r = runApp(cx);
mSleep(ms); --启动应用
if r == 0 then
if frontAppBid() == cx then
break
end
end
end
end
function shuru(wenzix)
local strt={}
for ch in string.gmatch(wenzix,"[\0-\x7f\xc2-\xf4][\x80-\xbf]*") do
table.insert(strt,ch)
end
toast("开始输入"..#strt.."个字",5)
for k,v in pairs(strt) do
inputText(v) --逐字输入
mSleep(math.random(500,800))
end
end
function rndLetter(num)--随机大小写
local ret = ""
pcall(function()
for var = 1,num do
if math.random()>0.5 then
ret = ret..string.char(math.random(65,90))
else
ret = ret..string.char(math.random(97,122))
end
end
end)
return ret
end
require "TSLib"
ts = require("ts")
--unlockDevice(); --解锁屏幕
--setBacklightLevel(0);setVolumeLevel(0)
ts_enterprise_lib = require("ts_enterprise_lib")
assert(ts_enterprise_lib,"无法引入企业专用库")
local category = "小红书作品链接"
math.randomseed(tostring(ts.ms()):reverse():sub(1, 6))
flag = deviceIsLock(); --判断屏幕是否锁定
if flag == 0 then
else
unlockDevice(); --解锁屏幕
end--开机自启动请勿使用此段代码,直接使用 unlockDevice 函数即可
closeApp("com.xingin.xhs")---关闭小红书
mSleep(1000)
for i=1,1000 do
local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","get_data",category)
if ok then
if ret1 then
openURL(ret2);
mSleep(1000)
for var= 1, 100 do
mSleep(100)
local glc = GetUIXml()
-- local fia3 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/yv","bounds")--关注数量
local fia4 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/likeLayout","bounds")--点赞
local fia3 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/yy","bounds")--关注
local dz_1 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/aat","text")--点赞数量
local dz_2 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/likeTextView","text")--点赞数量
local dz452 = FindXmlKey(glc,"text","添加评论…","class")--点赞数量
if fia3 or dz_1 or dz_2 or dz452 then
mSleep(1000)
if not fia4 then
touch():Step(50)n(200,1000):move(200,200)ff()
touch():Step(50)n(200,1000):move(200,200)ff()
end
mSleep(500)
local glc = GetUIXml()
local dz_1 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/aat","text")--点赞数量
local dz_2 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/likeTextView","text")--点赞数量
if dz_1 then
dz = dz_1
elseif dz_2 then
dz = dz_2
end
local sc_1 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/nw","text")--收藏数量
local sc_2 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/nz","text")--收藏数量
if sc_1 then
sc = sc_1
elseif sc_2 then
sc = sc_2
end
local pl_1 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/o7","text")--评论数量
local pl_2 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/commentTextView","text")--评论数量
if pl_1 then
pl = pl_1
elseif pl_2 then
pl = pl_2
end
local shijian = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/b0p","text")--发布时间
local data = {dz=dz,sc=sc,pl=pl,lianjie=ret2,shijian=shijian} --需要写入的数据
for var= 1, 10 do
local ok,err = ts_enterprise_lib:cloud_db_add('5d0be2726ce6ba000cc091d0',data,30)
if ok then
break
end
end
-- dialog("完成", time)
dz,sc,pl = nil
break
end
if FindXmlKey(glc,"text","等待","bounds") then
cik(FindXmlKey(glc,"text","等待","bounds"))
end
if var == 100 then
for i=1,10 do
local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","revert_data",category,ret2)
if ok and ret1 then
break
end
end
-- lua_exit(); --否则退出脚本
-- os.execute("reboot");
end
end
os.execute("input keyevent KEYCODE_BACK")
end
end
end--安卓发小红书
local function trimRN(str) --linux 上去除\r换行符,读取问题多是有符号和空格的原因
if str == nil then
return nil,"the string parameter is nil"
end
-- str = string.gsub(str, " ", "")
str = string.gsub(str,"\r","")
str = string.gsub(str,"\n","")
return str
end
function movefile(path,to)--帮你玩平台禁用此函数
os.execute("mv "..path.." "..to);
end
function click(x, y,ms)
local x,y=math.random(x,x+5),math.random(y-5,y)
touchDown(0, x, y)
mSleep(50)
touchUp(0, x, y)
if ms then mSleep(ms) else mSleep(50) end
end
function getList(path)--getList 遍历文件
local a = io.popen("ls "..path);
local f = {};
for l in a:lines() do
table.insert(f,l)
end
return f
end
function findFile(path)
local a = io.popen("find "..path.." -prune");
local f = {};
for l in a:lines() do
table.insert(f,l)
end
a:close()
return f
end
function serialize(obj)
local lua = ""
local t = type(obj)
if t == "number" then
lua = lua .. obj
elseif t == "boolean" then
lua = lua .. tostring(obj)
elseif t == "string" then
lua = lua .. string.format("%q", obj)
elseif t == "table" then
lua = lua .. "{\n"
for k, v in pairs(obj) do
lua = lua .. "[" .. serialize(k) .. "]=" .. serialize(v) .. ",\n"
end
local metatable = getmetatable(obj)
if metatable ~= nil and type(metatable.__index) == "table" then
for k, v in pairs(metatable.__index) do
lua = lua .. "[" .. serialize(k) .. "]=" .. serialize(v) .. ",\n"
end
end
lua = lua .. "}"
elseif t == "nil" then
return nil
else
error("can not serialize a " .. t .. " type.")
end
return lua
end
function unserialize(lua)
local t = type(lua)
if t == "nil" or lua == "" then
return nil
elseif t == "number" or t == "string" or t == "boolean" then
lua = tostring(lua)
else
error("can not unserialize a " .. t .. " type.")
end
lua = "return " .. lua
local func = loadstring(lua)
if func == nil then
return nil
end
return func()
end
function login(zuobiao,wenzi,ms)
cik(zuobiao)
shuru(wenzi)
mSleep(ms)
end
function fengexy(axz)--分割x,y轴
return string.match(axz, "[^%d]([%d-]*)[^%d]([%d]*)[^%d]*([%d]*)[^%d]([%d]*)")
end
function cik(dianji)
local x1,y1,x2,y2 = fengexy(dianji)
local xx = math.random(x1+5,x2-5)--缩小10个像素
local yy = math.random(y1+5,y2-5)--缩小10个像素
click(xx,yy,1000)
end
function ReadFile(path, isdel)-- 读取文件 [path:路径, isdel:是否删除] [返回文件内容, 失败返回空字符串]
local iRet, sRet = pcall(function()
local f = io.open(path, "r")
if f == null then
return ""
end
local ret = f:read("*all")
f:close()
if isdel then
os.remove(path)
end
return ret
end)
if iRet == true then
return sRet
else
return ""
end
end
function JsCmd(m)
local tmp
CMDAPK=userPath().."/res/JsAndroid.apk"
if(m==1)then
os.execute(string.format("nohup app_process -Djava.class.path=%s / com.jsdroid.core.JsMain &",CMDAPK))
elseif(m==2)then
os.execute(string.format("app_process -Djava.class.path=%s / com.jsdroid.core.JsMain",CMDAPK))
end
end
function Code(code)
local chaoshi=1
repeat
status_resp, header_resp,body_resp = ts.httpGet("http://127.0.0.1:9800?js="..code)
if body_resp then
zfdafd = true
if status_resp==200 and body_resp~=nil and string.len(body_resp)>1 then
break;
end
else
if status_resp==0 and header_resp~=nil and string.len(header_resp)>1 then
break;
end
end
chaoshi=chaoshi+1
mSleep(20)
if chaoshi>50 then
do return "sb" end
break;
end
until (false)
if zfdafd then
return body_resp
else
return header_resp
end
end
function IsStart(time)
local out = os.time() + time
local tmp
while(os.time()<out)do
tmp=Code("'start'")
if tmp=="start" then
do return true end
else
toast("mei-qi-dong",1)
end
mSleep(1000)
end
return false
end
function StartService(...)
JsCmd(1)
if IsStart(3)==false then
toast("方式一启动失败,尝试使用方式二")
-- mSleep(2000)
JsCmd(2)
if IsStart(3)==false then
-- dialog("启动服务失败!",0)
-- mSleep(2000)
-- lua_exit()
end
end
end
function GetUIXml()--获取XML文件
StartService()
return Code("getXml()")
end
function XmlToTable(xml)-- XML转Table
local iRet, sRet = pcall(function()
local tXml = {}
local i = 1
for k in xml:gmatch("<node[^>]+/?>") do
tXml[i] = {}
for w, y in k:gmatch("([a-zA-Z-]+)=\"([^\"]+)\"") do
tXml[i][w] = y
end
i = i + 1
end
return tXml
end)
if iRet == true then
return sRet
else
return ""
end
end
function FindXmlKeyA(Xml, key, val, key1)
local iRet, sRet = pcall(function()
local tXml = XmlToTable(Xml)
local tmptable = {}
for i = 1, #tXml do
if tXml[i][key] == val then
--table.insert(tmptable, tXml[i][key1]:match("\"(.+)\""))
--4-16修改 附近人表情昵称,不识别
table.insert(tmptable, tXml[i][key1])
end
end
if tmptable[1] == nil then
return nil
else
return tmptable
end
end)
if iRet == true then
return sRet
else
print(sRet)
return nil
end
end
function FindXmlKeyA_1(Xml, key, val,key_1, val_1,key1)
local iRet, sRet = pcall(function()
local tXml = XmlToTable(Xml)
local tmptable = {}
for i = 1, #tXml do
if tXml[i][key] == val and tXml[i][key_1] == val_1 then
--table.insert(tmptable, tXml[i][key1]:match("\"(.+)\""))
--4-16修改 附近人表情昵称,不识别
table.insert(tmptable, tXml[i][key1])
end
end
if tmptable[1] == nil then
return nil
else
return tmptable
end
end)
if iRet == true then
return sRet
else
print(sRet)
return nil
end
end
function FindXmlKey(Xml, key, val, key1)-- 查找XML字符串 [返回第一个查找到的字符串]
local iRet, sRet = pcall(function()
local tXml = XmlToTable(Xml)
local i = 1
for i = 1, #tXml do
if tXml[i][key] == val then
return tXml[i][key1]
end
end
return nil
end)
if iRet == true then
return sRet
else
return nil
end
end
function chengxu(cx,ms)
while true do
r = runApp(cx);
mSleep(ms); --启动应用
if r == 0 then
if frontAppBid() == cx then
break
end
end
end
end
function shuru(wenzix)
local strt={}
for ch in string.gmatch(wenzix,"[\0-\x7f\xc2-\xf4][\x80-\xbf]*") do
table.insert(strt,ch)
end
toast("开始输入"..#strt.."个字",5)
for k,v in pairs(strt) do
inputText(v) --逐字输入
mSleep(math.random(500,800))
end
end
function rndLetter(num)--随机大小写
local ret = ""
pcall(function()
for var = 1,num do
if math.random()>0.5 then
ret = ret..string.char(math.random(65,90))
else
ret = ret..string.char(math.random(97,122))
end
end
end)
return ret
end
require "TSLib"
ts = require("ts")
--unlockDevice(); --解锁屏幕
--setBacklightLevel(0);setVolumeLevel(0)
ts_enterprise_lib = require("ts_enterprise_lib")
assert(ts_enterprise_lib,"无法引入企业专用库")
local category = "小红书作品链接"
math.randomseed(tostring(ts.ms()):reverse():sub(1, 6))
flag = deviceIsLock(); --判断屏幕是否锁定
if flag == 0 then
else
unlockDevice(); --解锁屏幕
end--开机自启动请勿使用此段代码,直接使用 unlockDevice 函数即可
closeApp("com.xingin.xhs")---关闭小红书
mSleep(1000)
for i=1,1000 do
local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","get_data",category)
if ok then
if ret1 then
openURL(ret2);
mSleep(1000)
for var= 1, 100 do
mSleep(100)
local glc = GetUIXml()
-- local fia3 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/yv","bounds")--关注数量
local fia4 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/likeLayout","bounds")--点赞
local fia3 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/yy","bounds")--关注
local dz_1 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/aat","text")--点赞数量
local dz_2 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/likeTextView","text")--点赞数量
local dz452 = FindXmlKey(glc,"text","添加评论…","class")--点赞数量
if fia3 or dz_1 or dz_2 or dz452 then
mSleep(1000)
if not fia4 then
touch():Step(50)n(200,1000):move(200,200)ff()
touch():Step(50):on(200,1000):move(200,200):off()
end
mSleep(500)
local glc = GetUIXml()
local dz_1 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/aat","text")--点赞数量
local dz_2 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/likeTextView","text")--点赞数量
if dz_1 then
dz = dz_1
elseif dz_2 then
dz = dz_2
end
local sc_1 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/nw","text")--收藏数量
local sc_2 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/nz","text")--收藏数量
if sc_1 then
sc = sc_1
elseif sc_2 then
sc = sc_2
end
local pl_1 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/o7","text")--评论数量
local pl_2 = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/commentTextView","text")--评论数量
if pl_1 then
pl = pl_1
elseif pl_2 then
pl = pl_2
end
local shijian = FindXmlKey(glc,"resource-id","com.xingin.xhs:id/b0p","text")--发布时间
local data = {dz=dz,sc=sc,pl=pl,lianjie=ret2,shijian=shijian} --需要写入的数据
for var= 1, 10 do
local ok,err = ts_enterprise_lib:cloud_db_add('5d0be2726ce6ba000cc091d0',data,30)
if ok then
break
end
end
-- dialog("完成", time)
dz,sc,pl = nil
break
end
if FindXmlKey(glc,"text","等待","bounds") then
cik(FindXmlKey(glc,"text","等待","bounds"))
end
if var == 100 then
for i=1,10 do
local ok,ret1,ret2 = ts_enterprise_lib:plugin_api_call("DataCenter","revert_data",category,ret2)
if ok and ret1 then
break
end
end
-- lua_exit(); --否则退出脚本
-- os.execute("reboot");
end
end
os.execute("input keyevent KEYCODE_BACK")
end
end
end |