Добавил еще ведущие нули к миллисекундам, если кому-то еще когда-то этот код понадобится
log = function (text, color, define){ var id, time, thread, logHtml, textLog; define = (typeof define == 'string') ? define.split(/[\s,.|:;]+/g) : define; if(typeof define === 'object' && define !== null){ if(Array.isArray(define)){ id = define.indexOf('id') > -1; time = define.indexOf('time') > -1; thread = define.indexOf('thread') > -1; } else{ id = define.id == true; time = define.time == true; thread = define.thread == true; } } else id = time = thread = true; id = id ? '<a href="action://action' + ScriptWorker.GetCurrentAction() + '" style="color:gray;">[' + ScriptWorker.GetCurrentAction() + ']</a>' : ''; time = time ? ' ' + getTime() : ''; thread = thread ? ' Поток №' + thread_number() : ''; logHtml = (id || time || thread) ? id + '<span style="color: white">' + time + thread + ' : </span>' : ''; logHtml += '<span style="color:' + (color ? color : 'white') + '">' + text + '</span>'; textLog = '[' + ScriptWorker.GetCurrentAction() + ']' + time + thread + ' : ' + text function getTime(){ var checkTime = function(i){ return (i < 10) ? "0" + i : i; }; var checkMilliSeconds = function(ms){ if (ms < 10) { return "00" + ms; } else if (ms < 100) { return "0" + ms; } else { return ms; } }; var d = new Date(); var hh = checkTime(d.getHours()); var mm = checkTime(d.getMinutes()); var ss = checkTime(d.getSeconds()); var ms = checkMilliSeconds(d.getMilliseconds()); return '[' + hh + ':' + mm + ':' + ss + '.' + ms + ']'; }; Logger.WriteHtml(logHtml, textLog); }Как записать в переменную цифры из полученного элемента
-
Из кода текущего элемента : <div data-gameid="67345317" data-sportid="4" title="Statistics" class="c-events__ico c-events__ico_stat"></div>
, нужно цифры 67345317 записать в переменную.Пытался записать, установить переменную, т.к в java не шарю, ни чего не вышло.
Буду рад за помощь. -
XPATH>.//*[@id="games_content"]//div//div//div//div//div//div//div//div//div , вот с этого я получаю элемент кода
<div data-gameid="67345317" data-sportid="4" title="Statistics" class="c-events__ico c-events__ico_stat"></div>
нужно что, то дописать
-
@Alexx5l6 said in Как записать в переменную цифры из полученного элемента:
Из кода текущего элемента : <div data-gameid="67345317" data-sportid="4" title="Statistics" class="c-events__ico c-events__ico_stat"></div>
, нужно цифры 67345317 записать в переменную.Пытался записать, установить переменную, т.к в java не шарю, ни чего не вышло.
Буду рад за помощь.в BAS ни где не используется java.
Используйте действие "Получить Атрибут Элемента", с именем атрибута data-gameid

-
@Fox said in Как записать в переменную цифры из полученного элемента:
Получить Атрибут Элемента
спасибо, работает. нужно для парсера, чтобы был цикл, в цикле есть только код элемента
XPATH>.//*[@id="games_content"]//div//div//div//div//div//div//div//div//div, как раз получаются строчки
[775418673] [15:02:30] Поток №1 : Текущее повторение цикла : 0
[134561278] [15:02:33] Поток №1 : Код текущего элемента : <div data-gameid="67446673" data-sportid="4"
title="Statistics" class="c-events__ico c-events__ico_stat"></div>[775418673] [15:04:20] Поток №1 : Текущее повторение цикла : 1
[134561278] [15:04:22] Поток №1 : Код текущего элемента : <div data-gameid="67520385" data-sportid="4" title="Statistics" class="c-events__ico c-events__ico_stat"></div>по указаннаму вами кода выше получилось
XPATH> id("games_content")/div[1]/div[2]/div[1]/div[1]/div[@class="c-events__item c-events__item_col"]/div[@class="c-events__item c-events__item_game"]/div[@class="c-events__dop"]/div[@class="c-events__icons"]/div[@class="c-events__ico c-events__ico_stat"]
берет из переменной, код элемента.
на даный момент создать ресурс списка, потом в цикле обработать, каждую строчку взять цифры и потом уже подставлять в ссылку.
как можно сократить действия.
цикл парсир сразу цифры и записывал в список ресурса
на данный момент вот такой код

