Парсер многостраничного диалога

ratinov

Новичок
Автор темы
5
0
Версия MoonLoader
.026-beta
Я для себя хочу сделать парсер игроков в орге чтоб находить нужные мне ранги, спарсить одну страницу я могу, но как это же сделать с остальными?
Вид диалога
HqEM3rS.png
Мой код:
Lua:
local se = require "samp.events"

local file = io.open("ranks.txt", "w")

function split(str, delim, plain)
    local tokens, pos, plain = {}, 1, not (plain == false) --[[ delimiter is plain text by default ]]
    repeat
        local npos, epos = string.find(str, delim, pos, plain)
        table.insert(tokens, string.sub(str, pos, npos and npos - 1))
        pos = epos and epos + 1
    until not pos
    return tokens
end

function hasNeededRank(str)
    return string.match(str, "[78]") ~= nil
end

function se.onShowDialog(id, style, title, button1, button2, text)
    if id == 567 then
        local arr = split(text,"\n")
        for _, str in ipairs(arr) do
            if hasNeededRank(str) then
                file:write(str.. "\n")
            end
        end
        file:close()
    end
end
 

cord

contact me → cordtech.ru
Проверенный
557
410
Lua:
local samp = require("samp.events")

function samp.onShowDialog(id, style, title, button1, button2, text)
    local i = 0
    for str in text:gmatch('[^\r\n]+') do
        if not str:find("Ник%sигрока") and not str:find("Вперед%s>>>") then
           -- code
        elseif str:find("Вперед%s>>>") then
            sampSendDialogResponse(id, 1, i)
        end
        i = i + 1
    end
end
 
Последнее редактирование:
  • Нравится
Реакции: Vintik