Page 1 of 1

HTTPResponses array?

Posted: Monday 30 March 2020 13:48
by papoo
I wish query a website several times by changing a parameter for each request in the same script
with the domoticz.openURL command
httpTesponses can be an array?
how to recover the name of multiple httpresponses?
the beginning of my script

Code: Select all

local les_horoscopes = {} 
les_horoscopes[#les_horoscopes+1] = {device = 'Horoscope 1', signe = 'belier'}
les_horoscopes[#les_horoscopes+1] = {device = 'Horoscope 2',   signe = 'taureau'}
local horoscope = ''
local device = ''
local signe = ''
local site_url  = 'https://astro.rtl.fr/horoscope-jour-gratuit'  -- url


return {
    active = true,
    on  =   {
        timer           =   { 'every hour' },--https://www.domoticz.com/wiki/DzVents:_next_generation_LUA_scripting#timer_trigger_rules
        httpResponses   =   { 'belier, taureau, gemeaux, cancer, lion, vierge, balance, scorpion, sagittaire, capricorne, verseau, poissons' }    -- Trigger
    },
    execute = function(dz, item)

        local function logWrite(str,level)             -- Support function for shorthand debug log statements
            dz.log(tostring(str),level or dz.LOG_DEBUG)
        end

        if (item.isTimer) then
            for k,v in pairs(les_horoscopes) do-- On parcourt chaque horoscope
                device = v.device
                if device ~= nil and device ~= '' and dz.devices(device).name ~= nil then 
                    logWrite('--- --- --- traitement '..device..'  --- --- --') 
                    signe = v.signe
                    dz.openURL({--https://www.domoticz.com/wiki/DzVents:_next_generation_LUA_scripting#httpResponses
                        url = site_url..'/'..signe,
                        callback = signe
                    })
                end
            end --for
        end

        if (item.isHTTPResponse and item.ok) then
            for k,v in pairs(les_horoscopes) do-- On parcourt chaque horoscope
                device = v.device
                if device ~= nil and device ~= '' and dz.devices(device).name ~= nil then 
                    logWrite('--- --- --- traitement '..device..'  --- --- --') 
                    signe = v.signe
                    
                end
            end --for

--test the callback name or httpresponsename


        end
    end
    }

Re: HTTPResponses array?

Posted: Monday 30 March 2020 14:30
by boum
Just enumerate the different HTTP responses in the lua array:

Code: Select all

    on  =   {
        timer           =   { 'every hour' },
        httpResponses   =   { 'belier', 'taureau', 'gemeaux', 'cancer', 'lion', 'vierge', 'balance', 'scorpion', 'sagittaire', 'capricorne', 'verseau', 'poissons' }    -- Trigger
    },
In your script, when item.isHTTPResponse is true, you can get the corresponding string with item.trigger or item.callback.

Re: HTTPResponses array?

Posted: Monday 30 March 2020 14:43
by boum
To make things easier to change, I'd do something like that (feel free to use or not this version ;))

Code: Select all

local les_horoscopes = {
  ['belier'] = 'Horoscope 1',
  ['taureau'] = 'Horoscope 2',
} 
local site_url  = 'https://astro.rtl.fr/horoscope-jour-gratuit/'  -- url

return {
    active = true,
    on  =   {
        timer           =   { 'at 04:17' },
        httpResponses   =   { 'belier', 'taureau', 'gemeaux', 'cancer', 'lion', 'vierge', 'balance', 'scorpion', 'sagittaire', 'capricorne', 'verseau', 'poissons' }    -- Trigger
    },
    execute = function(dz, item)

        local function logWrite(str,level)             -- Support function for shorthand debug log statements
            dz.log(tostring(str),level or dz.LOG_DEBUG)
        end

        if (item.isTimer) then
            for signe,device in pairs(les_horoscopes) do-- On parcourt chaque horoscope
                if device and dz.devices(device).name then 
                    logWrite('--- --- --- traitement '..device..'  --- --- --') 
                    dz.openURL({--https://www.domoticz.com/wiki/DzVents:_next_generation_LUA_scripting#httpResponses
                        url = site_url..signe,
                        callback = signe
                    })
                end
            end --for
        elseif (item.isHTTPResponse and item.ok) then
            local signe = item.trigger
            local device = les_horoscopes[signe]
            if device and dz.devices(device).name then 
                logWrite('--- --- --- traitement '..device..'  --- --- --') 
            end
        end
    end
    }
It might even be possible to generate the httpResponses array from the les_horoscopes table automatically.

Re: HTTPResponses array?

Posted: Monday 30 March 2020 14:47
by waaren
papoo wrote: Monday 30 March 2020 13:48 I wish query a website several times by changing a parameter for each request in the same script
with the domoticz.openURL command
Could be something like

Code: Select all

return 
{
    on  =   
    {
        timer  =   
        { 
            'every minute' 
        },
        httpResponses =   
        { 
            'belier', 'taureau', 'gemeaux', 'cancer', 'lion', 'vierge', 'balance', 'scorpion', 'sagittaire', 'capricorne', 'verseau', 'poissons', 
        },
    },
    logging = 
    {
        level = domoticz.LOG_DEBUG,
        marker = 'horoscope',
    },

    execute = function(dz, item)

        local   les_horoscopes = 
        {
            { device = 'Horoscope 1', signe = 'belier'},
            { device = 'Horoscope 2', signe = 'taureau'},
            { device = 'Horoscope 3', signe = 'gemaux'},
        }
        local site_url  = 'https://astro.rtl.fr/horoscope-jour-gratuit/'  -- url

        local function logWrite(str,level)             -- Support function for shorthand debug log statements
            dz.log(tostring(str),level or dz.LOG_DEBUG)
        end

        if (item.isTimer) then
            for index, record in ipairs(les_horoscopes) do-- On parcourt chaque horoscope
                dz.utils.dumpTable(record)
                if dz.utils.deviceExists(record.device) then 
                    logWrite('--- --- --- traitement '.. record.device..'  --- --- --') 
                    dz.openURL(
                        {
                            url = site_url .. record.signe,
                            callback = record.signe
                        })
                end
            end --for
        end

        if (item.isHTTPResponse and item.ok) then
            for index, record in ipairs(les_horoscopes) do-- On parcourt chaque horoscope
                logWrite('--- --- --- traitement '..record.device..'  --- --- --') 
                if dz.utils.deviceExists(record.device) then
                    dz.log(item.data,dz.LOG_DEBUG) -- Just the html page ??
                    dz.devices(record.device).updateText(record.signe or 'no Horoscope today') 
                end
            end
        end
    end
}

Re: HTTPResponses array?

Posted: Monday 30 March 2020 14:52
by papoo
there is only one httpresponse, the first

how can i test each item.trigger in the if (item.isHTTPResponse) with a for boucle ?

do I have to create each test independently?

Re: HTTPResponses array?

Posted: Monday 30 March 2020 14:57
by boum
The script should be called 1 time for every dz.openURL call. Each time you will get a different item.trigger, so you'll have to update the device one by one.

Re: HTTPResponses array?

Posted: Monday 30 March 2020 15:02
by papoo
no only the first

two openurl but only one httpresponse processed
2020-03-30 14:58:00.467 Status: dzVents: Info: Horoscope v2.0: ------ Start external script: horoscope.lua:, trigger: "every 2 minutes"
2020-03-30 14:58:00.468 Status: dzVents: Debug: Horoscope v2.0: --- --- --- traitement Horoscope 1--- --- --
2020-03-30 14:58:00.468 Status: dzVents: Debug: Horoscope v2.0: OpenURL: url = https://astro.rtl.fr/horoscope-jour-gratuit/cancer
2020-03-30 14:58:00.468 Status: dzVents: Debug: Horoscope v2.0: OpenURL: method = GET
2020-03-30 14:58:00.468 Status: dzVents: Debug: Horoscope v2.0: OpenURL: post data = nil
2020-03-30 14:58:00.468 Status: dzVents: Debug: Horoscope v2.0: OpenURL: headers = nil
2020-03-30 14:58:00.468 Status: dzVents: Debug: Horoscope v2.0: OpenURL: callback = cancer
2020-03-30 14:58:00.468 Status: dzVents: Debug: Horoscope v2.0: --- --- --- traitement Horoscope 2 --- --- --
2020-03-30 14:58:00.468 Status: dzVents: Debug: Horoscope v2.0: OpenURL: url = https://astro.rtl.fr/horoscope-jour-gratuit/capricorne
2020-03-30 14:58:00.468 Status: dzVents: Debug: Horoscope v2.0: OpenURL: method = GET
2020-03-30 14:58:00.468 Status: dzVents: Debug: Horoscope v2.0: OpenURL: post data = nil
2020-03-30 14:58:00.468 Status: dzVents: Debug: Horoscope v2.0: OpenURL: headers = nil
2020-03-30 14:58:00.468 Status: dzVents: Debug: Horoscope v2.0: OpenURL: callback = capricorne
2020-03-30 14:58:00.469 Status: dzVents: Info: Horoscope v2.0: ------ Finished horoscope.lua
2020-03-30 14:58:01.550 Status: dzVents: Info: Horoscope v2.0: ------ Start external script: horoscope.lua: HTTPResponse: "cancer"
2020-03-30 14:58:01.550 Status: dzVents: Debug: Horoscope v2.0: --- --- --- traitement --- --- --
2020-03-30 14:58:01.557 Status: dzVents: Debug: Horoscope v2.0: Processing device-adapter for Horoscope Pascal: Text device
2020-03-30 14:58:01.557 Status: dzVents: Debug: Horoscope v2.0: --- --- --- traitement Horoscope 1 --- --- --
2020-03-30 14:58:01.557 Status: dzVents: Debug: Horoscope v2.0: --- --- --- traitement signe cancer --- --- --
2020-03-30 14:58:01.559 Status: dzVents: Debug: Horoscope v2.0: En ce qui vous concerne, Mars et Saturne sont en lien avec le domaine financier, il y a évidemment une crise dans ce domaine, accentuée semble-t-il pour ceux de juin.
2020-03-30 14:58:01.560 Status: dzVents: Debug: Horoscope v2.0: Processing device-adapter for Horoscope 2: Text device
2020-03-30 14:58:01.560 Status: dzVents: Debug: Horoscope v2.0: --- --- --- traitement Horoscope Lina --- --- --
2020-03-30 14:58:01.560 Status: dzVents: Info: Horoscope v2.0: ------ Finished horoscope.lua
with this code

Code: Select all

        if (item.isHTTPResponse and item.ok) then
                    logWrite('--- --- --- traitement   --- --- --')
            for index,record in pairs(les_horoscopes) do-- On parcourt chaque horoscope
                device = record.device
                if device ~= nil and device ~= '' and dz.devices(device).name ~= nil then
                    logWrite('--- --- --- traitement '..device..'  --- --- --')
                    signe = record.signe
                    if item.trigger == signe then
                        logWrite('--- --- --- traitement signe '..item.trigger..'  --- --- --')

                        for instance in item.data:gmatch("<body>(.-)</body>") do
                            div, horoscope=instance:match('<h2>En résumé</h2>(.-)<p class="text">(.-)</p>')
                        end
                        horoscope = TronquerTexte(unescape(horoscope), 240)
                        logWrite(horoscope)
                        
                    end
                end
            end --for
        end

Re: HTTPResponses array?

Posted: Monday 30 March 2020 15:20
by boum
I tried locally and got 2 triggers (I kept only those in your first script)
2020-03-30 15:15:13.693 Status: dzVents: Info: ------ Start internal script: horoscope: Device: "Switch (Dummy)", Index: 1
2020-03-30 15:15:13.697 Status: dzVents: Info: ------ Finished horoscope
2020-03-30 15:15:14.036 Status: dzVents: Info: Handling httpResponse-events for: "belier"
2020-03-30 15:15:14.036 Status: dzVents: Info: ------ Start internal script: horoscope: HTTPResponse: "belier"
2020-03-30 15:15:14.051 Status: dzVents: belier
2020-03-30 15:15:14.052 Status: dzVents: Horoscope 1
2020-03-30 15:15:14.052 Status: dzVents: ok
2020-03-30 15:15:14.056 Status: dzVents: Info: ------ Finished horoscope
2020-03-30 15:15:14.222 Status: dzVents: Info: Handling httpResponse-events for: "taureau"
2020-03-30 15:15:14.222 Status: dzVents: Info: ------ Start internal script: horoscope: HTTPResponse: "taureau"
2020-03-30 15:15:14.237 Status: dzVents: taureau
2020-03-30 15:15:14.237 Status: dzVents: Horoscope 2
2020-03-30 15:15:14.237 Status: dzVents: ok
2020-03-30 15:15:14.240 Status: dzVents: Info: ------ Finished horoscope
Weird.

Re: HTTPResponses array?

Posted: Monday 30 March 2020 15:27
by papoo
with witch code?
with mine there is only one httpresponse
the 2 responses is same

Code: Select all

2020-03-30 15:22:01.446 Status: dzVents: Info: Horoscope v2.0: ------ Start external script: horoscope.lua: HTTPResponse: "cancer"
2020-03-30 15:22:01.446 Status: dzVents: Debug: Horoscope v2.0: --- --- --- traitement Horoscope 1 --- --- --
2020-03-30 15:22:01.448 Status: dzVents: Debug: Horoscope v2.0: En ce qui vous concerne, Mars et Saturne sont en lien avec le domaine financier, il y a évidemment une crise dans ce domaine, accentuée semble-t-il pour ceux de juin.
2020-03-30 15:22:01.455 Status: dzVents: Debug: Horoscope v2.0: Processing device-adapter for Horoscope 1: Text device
2020-03-30 15:22:01.455 Status: dzVents: Debug: Horoscope v2.0: --- --- --- traitement Horoscope 2 --- --- --
2020-03-30 15:22:01.457 Status: dzVents: Debug: Horoscope v2.0: En ce qui vous concerne, Mars et Saturne sont en lien avec le domaine financier, il y a évidemment une crise dans ce domaine, accentuée semble-t-il pour ceux de juin.
2020-03-30 15:22:01.458 Status: dzVents: Debug: Horoscope v2.0: Processing device-adapter for Horoscope 2: Text device
2020-03-30 15:22:01.458 Status: dzVents: Info: Horoscope v2.0: ------ Finished horoscope.lua

Re: HTTPResponses array?

Posted: Monday 30 March 2020 15:36
by boum
I used this:

Code: Select all

return {
    on  =   {
		devices = {			'Switch'		},
        httpResponses   =   { 'belier', 'taureau', 'gemeaux', 'cancer', 'lion', 'vierge', 'balance', 'scorpion', 'sagittaire', 'capricorne', 'verseau', 'poissons' }    -- Trigger
    },
    execute = function(dz, item)
        local les_horoscopes = {
          ['belier'] = 'Horoscope 1',
          ['taureau'] = 'Horoscope 2',
        } 
        local site_url  = 'https://astro.rtl.fr/horoscope-jour-gratuit/'  -- url

        local function logWrite(str,level)             -- Support function for shorthand debug log statements
            dz.log(tostring(str),level or dz.LOG_DEBUG)
        end
        
        if not item.isHTTPResponse then
            for signe,device in pairs(les_horoscopes) do
                if device and dz.devices(device).name then 
                    logWrite('--- --- --- traitement '..device..'  --- --- --') 
                    dz.openURL({
                        url = site_url..signe,
                        callback = signe
                    })
                end
            end --for
        elseif item.isHTTPResponse and item.ok then
            local signe = item.trigger
            local device = les_horoscopes[signe]
            print(signe, device, (item.ok and 'ok' or 'KO'))
        end
    end
}

Re: HTTPResponses array?

Posted: Monday 30 March 2020 15:50
by papoo
mea culpa, to test I had reduced httpresponses to a single item and forgot to put it back to normal

Re: HTTPResponses array?  [Solved]

Posted: Monday 30 March 2020 16:38
by papoo
thanks boum and waaren
my finished script

Code: Select all

--[[
name : script_time_horoscope.lua
auteur : papoo
Mise à jour : 30/03/2020
Création : 26/06/2016 =>V1.x https://github.com/papo-o/domoticz_scripts/blob/master/Lua/script_time_horoscope.lua
https://pon.fr/dzvents-horoscope-v2
https://easydomoticz.com/forum/
github : https://github.com/papo-o/domoticz_scripts/blob/master/dzVents/scripts/horoscope.lua
Principe :
 Ce script vérifie toutes les x heures les horoscopes du site <a href="https://astro.rtl.fr/horoscope-jour-gratuit">astro.rtl.fr</a> signe par signe et mets à jour les éventuels devices texte associés sur domoticz


]]--
local les_horoscopes = {
            { device = 'Horoscope 1',  signe = 'belier'},
            { device = 'Horoscope 2',    signe = 'capricorne'},
            { device = 'Horoscope 3',  signe = 'vierge'},
            { device = 'Horoscope 4',    signe = 'balance'},
                        }
local horoscope = ''
local device = ''
local signe = ''
local site_url  = 'https://astro.rtl.fr/horoscope-jour-gratuit'  -- url
--------------------------------------------
----------- Fin variables à éditer ---------
--------------------------------------------
local scriptName        = 'Horoscope'
local scriptVersion     = '2.0'

return {
    active = true,
    on  =   {
        timer           =   { 'every 6 hours' },--https://www.domoticz.com/wiki/DzVents:_next_generation_LUA_scripting#timer_trigger_rules
        httpResponses   =   { 'belier','taureau','gemeaux','cancer','lion','vierge','balance','scorpion','sagittaire','capricorne','verseau','poissons' }    -- Trigger
        --httpResponses   =   { 'cancer','capricorne' }    -- Trigger
    },
    logging =   {
        level    =   domoticz.LOG_DEBUG,                -- Seulement un niveau peut être actif; commenter les autres
        -- level    =   domoticz.LOG_INFO,              -- Only one level can be active; comment others
        -- level    =   domoticz.LOG_ERROR,
        -- level    =   domoticz.LOG_MODULE_EXEC_INFO,
     marker = scriptName..' v'..scriptVersion },
    execute = function(dz, item)

        local function logWrite(str,level)              -- Support function for shorthand debug log statements
            dz.log(tostring(str),level or dz.LOG_DEBUG)
        end
--------------------------------------------
        local function TronquerTexte(texte, nb)  -- texte à tronquer, Nb maximum de caractère
        local sep ="[?;!.]"
        local DernierIndex = nil
        texte = string.sub(texte, 1, nb)
        local p = string.find(texte, sep, 1)
        DernierIndex = p
        while p do
            p = string.find(texte, sep, p + 1)
            if p then
                DernierIndex = p
            end
        end
        return(string.sub(texte, 1, DernierIndex))
        end
--------------------------------------------
function unescape(str)--remplace le code html
    if (str) then
    str = string.gsub( str, '&nbsp;', ' ')
    str = string.gsub( str, '&iexcl;', '¡')
    str = string.gsub( str, '&cent;', '¢')
    str = string.gsub( str, '&pound;', '£')
    str = string.gsub( str, '&curren;', '¤')
    str = string.gsub( str, '&yen;', '¥')
    str = string.gsub( str, '&brvbar;', '¦')
    str = string.gsub( str, '&sect;', '§')
    str = string.gsub( str, '&uml;', '¨')
    str = string.gsub( str, '&copy;', '©')
    str = string.gsub( str, '&ordf;', 'ª')
    str = string.gsub( str, '&laquo;', '«')
    str = string.gsub( str, '&not;', '¬')
    str = string.gsub( str, '&shy;', '­')
    str = string.gsub( str, '&reg;', '®')
    str = string.gsub( str, '&macr;', '¯')
    str = string.gsub( str, '&deg;', '°')
    str = string.gsub( str, '&plusmn;', '±')
    str = string.gsub( str, '&sup2;', '²')
    str = string.gsub( str, '&sup3;', '³')
    str = string.gsub( str, '&acute;', '´')
    str = string.gsub( str, '&micro;', 'µ')
    str = string.gsub( str, '&para;', '¶')
    str = string.gsub( str, '&middot;', '·')
    str = string.gsub( str, '&cedil;', '¸')
    str = string.gsub( str, '&sup1;', '¹')
    str = string.gsub( str, '&ordm;', 'º')
    str = string.gsub( str, '&raquo;', '»')
    str = string.gsub( str, '&frac14;', '¼')
    str = string.gsub( str, '&frac12;', '½')
    str = string.gsub( str, '&frac34;', '¾')
    str = string.gsub( str, '&iquest;', '¿')
    str = string.gsub( str, '&Agrave;', 'À')
    str = string.gsub( str, '&Aacute;', 'Á')
    str = string.gsub( str, '&Acirc;', 'Â')
    str = string.gsub( str, '&Atilde;', 'Ã')
    str = string.gsub( str, '&Auml;', 'Ä')
    str = string.gsub( str, '&Aring;', 'Å')
    str = string.gsub( str, '&AElig;', 'Æ')
    str = string.gsub( str, '&Ccedil;', 'Ç')
    str = string.gsub( str, '&Egrave;', 'È')
    str = string.gsub( str, '&Eacute;', 'É')
    str = string.gsub( str, '&Ecirc;', 'Ê')
    str = string.gsub( str, '&Euml;', 'Ë')
    str = string.gsub( str, '&Igrave;', 'Ì')
    str = string.gsub( str, '&Iacute;', 'Í')
    str = string.gsub( str, '&Icirc;', 'Î')
    str = string.gsub( str, '&Iuml;', 'Ï')
    str = string.gsub( str, '&ETH;', 'Ð')
    str = string.gsub( str, '&Ntilde;', 'Ñ')
    str = string.gsub( str, '&Ograve;', 'Ò')
    str = string.gsub( str, '&Oacute;', 'Ó')
    str = string.gsub( str, '&Ocirc;', 'Ô')
    str = string.gsub( str, '&Otilde;', 'Õ')
    str = string.gsub( str, '&Ouml;', 'Ö')
    str = string.gsub( str, '&times;', '×')
    str = string.gsub( str, '&Oslash;', 'Ø')
    str = string.gsub( str, '&Ugrave;', 'Ù')
    str = string.gsub( str, '&Uacute;', 'Ú')
    str = string.gsub( str, '&Ucirc;', 'Û')
    str = string.gsub( str, '&Uuml;', 'Ü')
    str = string.gsub( str, '&Yacute;', 'Ý')
    str = string.gsub( str, '&THORN;', 'Þ')
    str = string.gsub( str, '&szlig;', 'ß')
    str = string.gsub( str, '&agrave;', 'à')
    str = string.gsub( str, '&aacute;', 'á')
    str = string.gsub( str, '&acirc;', 'â')
    str = string.gsub( str, '&atilde;', 'ã')
    str = string.gsub( str, '&auml;', 'ä')
    str = string.gsub( str, '&aring;', 'å')
    str = string.gsub( str, '&aelig;', 'æ')
    str = string.gsub( str, '&ccedil;', 'ç')
    str = string.gsub( str, '&egrave;', 'è')
    str = string.gsub( str, '&eacute;', 'é')
    str = string.gsub( str, '&ecirc;', 'ê')
    str = string.gsub( str, '&euml;', 'ë')
    str = string.gsub( str, '&igrave;', 'ì')
    str = string.gsub( str, '&iacute;', 'í')
    str = string.gsub( str, '&icirc;', 'î')
    str = string.gsub( str, '&iuml;', 'ï')
    str = string.gsub( str, '&eth;', 'ð')
    str = string.gsub( str, '&ntilde;', 'ñ')
    str = string.gsub( str, '&ograve;', 'ò')
    str = string.gsub( str, '&oacute;', 'ó')
    str = string.gsub( str, '&ocirc;', 'ô')
    str = string.gsub( str, '&otilde;', 'õ')
    str = string.gsub( str, '&ouml;', 'ö')
    str = string.gsub( str, '&divide;', '÷')
    str = string.gsub( str, '&oslash;', 'ø')
    str = string.gsub( str, '&ugrave;', 'ù')
    str = string.gsub( str, '&uacute;', 'ú')
    str = string.gsub( str, '&ucirc;', 'û')
    str = string.gsub( str, '&uuml;', 'ü')
    str = string.gsub( str, '&yacute;', 'ý')
    str = string.gsub( str, '&thorn;', 'þ')
    str = string.gsub( str, '&yuml;', 'ÿ')
    str = string.gsub( str, '&euro;', '€')
    str = string.gsub( str, '&#(%d+);', function(n) return string.char(n) end )
    str = string.gsub( str, '&#x(%d+);', function(n) return string.char(tonumber(n,16)) end )
    str = string.gsub( str, '&amp;', '&' ) -- Be sure to do this after all others
     end
    return (str)
end

--------------------------------------------
        if (item.isTimer) then
            for index,record in pairs(les_horoscopes) do-- On parcourt chaque horoscope
                device = record.device
                if device ~= nil and device ~= '' and dz.devices(device).name ~= nil then
                    logWrite('--- --- --- traitement '..device..'  --- --- --')
                    signe = record.signe
                    dz.openURL({--https://www.domoticz.com/wiki/DzVents:_next_generation_LUA_scripting#httpResponses
                        url = site_url..'/'..signe,
                        callback = signe
                    })
                end
            end --for
        end

        if (item.isHTTPResponse and item.ok) then
                    logWrite('--- --- --- traitement   --- --- --')
            for index,record in pairs(les_horoscopes) do-- On parcourt chaque horoscope
                device = record.device
                if dz.utils.deviceExists(record.device) then
                    logWrite('--- --- --- traitement '..device..'  --- --- --')
                    signe = record.signe
                    if item.trigger == signe then
                        logWrite('--- --- --- traitement signe '..item.trigger..'  --- --- --')
                        for instance in item.data:gmatch("<body>(.-)</body>") do
                            div, horoscope=instance:match('<h2>En résumé</h2>(.-)<p class="text">(.-)</p>')
                        end
                        horoscope = TronquerTexte(unescape(horoscope), 240)
                        logWrite(horoscope)
                        dz.devices(record.device).updateText(horoscope or 'Pas d\'horoscope aujourd\'hui') 
                    end
                end
            end --for
        end

     end
    }