Skip to content
  • Home
  • Recent
  • Tags
  • 0 Unread 0
  • Categories
  • Unreplied
  • Popular
  • GitHub
  • Docu
  • Hilfe
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
ioBroker Logo

Community Forum

donate donate
  1. ioBroker Community Home
  2. Русский
  3. ioBroker
  4. Скрипты
  5. ioBroker скрипты
  6. Альтернатива - request(url).

NEWS

  • Monatsrückblick Januar/Februar 2026 ist online!
    BluefoxB
    Bluefox
    17
    1
    505

  • Jahresrückblick 2025 – unser neuer Blogbeitrag ist online! ✨
    BluefoxB
    Bluefox
    17
    1
    5.2k

  • Neuer Blogbeitrag: Monatsrückblick - Dezember 2025 🎄
    BluefoxB
    Bluefox
    13
    1
    1.4k

Альтернатива - request(url).

Scheduled Pinned Locked Moved ioBroker скрипты
11 Posts 3 Posters 4.4k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    IZUM
    wrote on last edited by
    #1

    В CCU.IO была функция request(url), какая функция в ioBroker выполняет ту же задачу?

    в описании не нашел подобных функций https://github.com/ioBroker/ioBroker.ja … 2015-03-06

    1 Reply Last reply
    0
    • V Offline
      V Offline
      vtec
      wrote on last edited by
      #2
      var http = require('http');
          // Read http://www.google.com page
          http.request('www.google.com', function(res) {
                res.setEncoding('utf8');
          }).on('error', function(e) {
                log('problem with request: ' + e.message, 'error');
          });
      

      оно?

      Правда данный пример почему то вызывает ошибку: problem with request: connect ECONNREFUSED

      1 Reply Last reply
      0
      • I Offline
        I Offline
        IZUM
        wrote on last edited by
        #3

        @vtec:

        var http = require('http');
            // Read http://www.google.com page
            http.request('www.google.com', function(res) {
                  res.setEncoding('utf8');
            }).on('error', function(e) {
                  log('problem with request: ' + e.message, 'error');
            });
        

        оно?

        Правда данный пример почему то вызывает ошибку: problem with request: connect ECONNREFUSED `

        он прописывает ошибку в лог от сюда log('problem with request: ' + e.message, 'error');

        1 Reply Last reply
        0
        • V Offline
          V Offline
          vtec
          wrote on last edited by
          #4

          Да это понятно, просто почему в ошибку валит.

          Вот что нашел в описании: Following modules are pre-loaded: fs, crypto, wake_on_lan, request, suncalc, util, path, os, net, events, dns.

          1 Reply Last reply
          0
          • V Offline
            V Offline
            vtec
            wrote on last edited by
            #5

            Bluefox, подскажи нам как request(url)?
            483_widget_anleitung.png

            1 Reply Last reply
            0
            • BluefoxB Offline
              BluefoxB Offline
              Bluefox
              wrote on last edited by
              #6

              @Bluefox:

              var request = require('request');
              request('http://www.google.com', function (error, response, body) {
                if (!error && response.statusCode == 200) {
                  log(body) // Show the HTML for the Google homepage. 
                }
              })
              

              Почему не работает http.request разберусь завтра вечером. У меня завтра экзамен. `

              Мы за тебя держим кулочки!

              1 Reply Last reply
              0
              • V Offline
                V Offline
                vtec
                wrote on last edited by
                #7

                Еще как вариант, проверил, работает.

                exec ('wget --output-document=/dev/null "http://192.168.0.14/sec/?pt=7&cmd=7:0"');
                
                1 Reply Last reply
                0
                • BluefoxB Offline
                  BluefoxB Offline
                  Bluefox
                  wrote on last edited by
                  #8

                  @vtec:

                  Еще как вариант, проверил, работает.

                  exec ('wget --output-document=/dev/null "http://192.168.0.14/sec/?pt=7&cmd=7:0"');
                  ```` `  
                  

                  Это только для linux

                  1 Reply Last reply
                  0
                  • BluefoxB Offline
                    BluefoxB Offline
                    Bluefox
                    wrote on last edited by
                    #9

                    Наконец то нашёл в чём загвоздка:

                    var http = require('http');
                    http.request({
                        hostname: 'www.google.com'
                    }, function(res) {
                        res.setEncoding('utf8');
                        var body = '';
                        res.on('data', function (chunk) {
                            body += chunk;
                        }).on('end', function () {
                            log(body);
                        })
                    }).on('error', function(e) {
                        log('problem with request: ' + e.message, 'error');
                    }).end();
                    

                    end() в конце очень важно.

                    Причём:````
                    http.request('www.google.com', ...)

                    не работает.
                    
                    Я советую использовать модуль request, а не http
                    1 Reply Last reply
                    0
                    • V Offline
                      V Offline
                      vtec
                      wrote on last edited by
                      #10

                      request не работает.

                      var url = 'http://192.168.0.14/sec/?pt=7&cmd=7:1';
                      var http = require('request');
                      http.request(url);
                      
                      

                      log

                      javascript-0 2015-03-17 10:33:29 error at script.js.Test:3:6

                      javascript-0 2015-03-17 10:33:29 error } has no method 'request'

                      javascript-0 2015-03-17 10:33:29 error return new request.Request(options)

                      javascript-0 2015-03-17 10:33:29 error options.uri = params.uri

                      javascript-0 2015-03-17 10:33:29 error options.callback = params.callback

                      javascript-0 2015-03-17 10:33:29 error options = params.options

                      javascript-0 2015-03-17 10:33:29 error var params = initParams(uri, options, callback)

                      javascript-0 2015-03-17 10:33:29 error }

                      javascript-0 2015-03-17 10:33:29 error throw new Error('undefined is not a valid uri or options object.')

                      javascript-0 2015-03-17 10:33:29 error if (typeof uri === 'undefined') {

                      javascript-0 2015-03-17 10:33:29 error script.js.Test: TypeError: Object function request(uri, options, callback) {

                      javascript-0 2015-03-17 10:33:29 info Start javascript script.js.Test

                      1 Reply Last reply
                      0
                      • BluefoxB Offline
                        BluefoxB Offline
                        Bluefox
                        wrote on last edited by
                        #11

                        @vtec:

                        request не работает.

                        var url = 'http://192.168.0.14/sec/?pt=7&cmd=7:1';
                        var http = require('request');
                        http.request(url);
                        
                        

                        log

                        javascript-0 2015-03-17 10:33:29 error at script.js.Test:3:6

                        javascript-0 2015-03-17 10:33:29 error } has no method 'request'

                        javascript-0 2015-03-17 10:33:29 error return new request.Request(options)

                        javascript-0 2015-03-17 10:33:29 error options.uri = params.uri

                        javascript-0 2015-03-17 10:33:29 error options.callback = params.callback

                        javascript-0 2015-03-17 10:33:29 error options = params.options

                        javascript-0 2015-03-17 10:33:29 error var params = initParams(uri, options, callback)

                        javascript-0 2015-03-17 10:33:29 error }

                        javascript-0 2015-03-17 10:33:29 error throw new Error('undefined is not a valid uri or options object.')

                        javascript-0 2015-03-17 10:33:29 error if (typeof uri === 'undefined') {

                        javascript-0 2015-03-17 10:33:29 error script.js.Test: TypeError: Object function request(uri, options, callback) {

                        javascript-0 2015-03-17 10:33:29 info Start javascript script.js.Test `

                        var url = 'http://192.168.0.14/sec/?pt=7&cmd=7:1';
                        var request = require('request');
                        request(url);
                        
                        
                        1 Reply Last reply
                        0
                        Reply
                        • Reply as topic
                        Log in to reply
                        • Oldest to Newest
                        • Newest to Oldest
                        • Most Votes


                        Support us

                        ioBroker
                        Community Adapters
                        Donate

                        661

                        Online

                        32.7k

                        Users

                        82.5k

                        Topics

                        1.3m

                        Posts
                        Community
                        Impressum | Datenschutz-Bestimmungen | Nutzungsbedingungen | Einwilligungseinstellungen
                        ioBroker Community 2014-2025
                        logo
                        • Login

                        • Don't have an account? Register

                        • Login or register to search.
                        • First post
                          Last post
                        0
                        • Home
                        • Recent
                        • Tags
                        • Unread 0
                        • Categories
                        • Unreplied
                        • Popular
                        • GitHub
                        • Docu
                        • Hilfe