You are reading a single comment by @tempos and its replies. Click here to read the full conversation.
  • Hello!
    I'm trying to parse xml from url. My code looks like:

    var wifi = require("Wifi");
    function getFeed(){
          var options = {
                method: 'GET',
                host: "http://www.upwork.com",
                port: 443,
                path: "/ab/feed/jobs/rss",
                protocol:"https"
          };
         var contents = "";
         var req = require('http').request(options, function(res) {
                console.log(res);
                res.on('data', function(data) {
                      contents += data;
                      console.log(contents);
                });
                res.on('close', function() {
                    console.log('CLOSE');
                    contents = "";
                });
      });
      req.on('error', function(e) {
                console.log('Error');
                console.log(e);
       });
      req.end();
    }
    wifi.connect("ssid", {password:"pass"}, function(err){ 
      if (err) {
        console.log("Connection error: "+err);
        return;
      }
      getFeed();
      console.log("connected? err=", err, "info=", wifi.getIP());
    });
    

    And I got response:

    httpCRs {
      "headers": {
        "Server": "cloudflare-nginx",
        "Date": "Mon, 25 Dec 2017 18:01:36 GMT",
        "Content-Type": "text/html",
        "Content-Length": "177",
        "Connection": "close",
        "CF-RAY": "-"
       },
      "httpVersion": "1.1",
      "statusCode": "400",
      "statusMessage": "Bad Request"
     }
    <html>
    <head><title>400 Bad Request</title></head>
    <body bgcolor="white">
    <center><h1>400 Bad Requ
    <html>
    <head><title>400 Bad Request</title></head>
    <body bgcolor="white">
    <center><h1>400 Bad Request</h1></center>
    <hr><center>cloudflare-nginx</center>
    </body>
    </html>
    CLOSE
    

    Seems espruino tries to get host by it's IP, but as I know target site is not accessible by it's IP. Typing url

    https://www.upwork.com/ab/feed/jobs/rss

    in browser's address line will return rss feed

    So my question is there any workaround for that?

    Would appreciate any help

About

Avatar for tempos @tempos started