Import table from HTML into Matlab

512
November 23, 2016, at 4:45 PM

I am trying to import data from an html webpage into Matlab. I have come across a function "getTableFromWeb". It looks pretty cool. The problem is when I use a browser for example Firefox I can see the data. But when use this function it can't find any table. Even when I save the html file from browser it only save the code. There is no data. I don't know anything about java html programming. But I read many many relevant questions but I can't find the answer to my problem. I used Inspect Element in Firefox. It shows in the Debugger, the bootstrap.js and jquery.js and list.html. I appreciate any help.

get("http://laaablaaablaaablaaaab is similiar to the url I use to see the data but not identical.

Thanks in advance.

<head lang="en">
                     <meta charset="UTF-8">
       <meta name="viewport" content="width=device-width, initial-scale=1">
      <title>laablaablaab/title>
<link rel="stylesheet" href="bower_components/bootstrap/dist/css/bootstrap.css"/>
<style>
    .table{
        font-size: 8px;
    }
 </style>
</head>
 <body>
<nav class="navbar navbar-default">
<div class="container">
    <div class="navbar-header">
        <a class="navbar-brand" href="#">
        <ul class="nav navbar-nav">
            <li><a href="index.html">Home</a></li>
            <li><a href="register.html">Register name</a></li>
            <li><a href="guide.html">Guide</a></li>
        </ul>
       </div>
   </div>
   </nav>
      <div class="container">
   <table class="table table-striped">
    <thead>
    <tr>
        <th>Id</th>
        <th>Time</th>
        <th>U L1</th>
        <th>Powerlvl adj max</th>
        <th>VAR Q<small>abs</small></th>
        <th>VAR Q<small>abs</small> lead or lag</th>
               </tr>
    </thead>
    <tbody id="tbody"></tbody>
    <tfoot>
    <nav>
        <ul class="pager">
            <li class="previous disabled"><a id="pvpg" href="#"><span    aria-hidden="true">&larr;</span> Older</a>
            </li>
            <li class="next"><a id="nxtpg" href="#">Newer <span aria-hidden="true">&rarr;</span></a></li>
        </ul>
    </nav>
    </tfoot>
</table>
</div>
 <script src="bower_components/jquery/dist/jquery.js"></script>
  <script src="bower_components/bootstrap/dist/js/bootstrap.js"></script>
 <script>
var index = 0;
    var Name = getQueryParameters().name;
  var pages = 50;
  var num = getNumberMeasurements(inverterName);
var nextpager = document.getElementById("nxtpg");
var previouspager = document.getElementById("pvpg");
   getMeasurements(inName, index, pages);
nextpager.onclick = function () {
    if (index >= num / pages)
        return;
    index++;
    getMeasurements(Name, index, pages);
};
previouspager.onclick = function () {
    if (index == 0)
        return;
    index--;
    getMeasurements(Name, index, pages);
};
function handlePagerBtns() {
    var calculated = 0;
    if (num > 0){
        calculated = Math.ceil(num/pages);
    }
    if (index >= calculated) {
        var li = nextpager.parentNode;
        li.className = "next disabled";
    }
    else {
        var li = nextpager.parentNode;
        li.className = "next";
    }
    if (index == 0) {
        var li = previouspager.parentNode;
        li.className = "previous disabled"
    } else {
        var li = previouspager.parentNode;
        li.className = "previous"
    }
}
function getNumberMeasurements(name) {
    var num = 1000;
    return num;
}
function getMeasurements(name, skip, top) {
    handlePagerBtns();
    var tbody = document.getElementById("tbody");
    tbody.innerHTML = "";
    $.get("http://laaablaaablaaablaaaab('" + name + "')/Measurement?$orderby=LogTime+desc&$skip=" + skip*top + "+&$top=" + top, {})
            .done(function (data) {
                data.value.forEach(function (measurement) {
                    var trow = document.createElement("TR");
                    for (var k in measurement) {
                        if (k == "_Name")
                            continue;
                        var tcell = document.createElement("TD");
                        if (k == "Id" || k == "LogTime") {
                            tcell.innerHTML = measurement[k];
                        }
                        else if (k == "ReactivePowerQabsIsLag" || k == "ReactivePowerCosPhiIsLag") {
                            tcell.innerHTML = measurement[k];
                        }
                        else {
                            if (measurement[k] != null)
                                tcell.innerHTML = measurement[k].toFixed(2);
                        }
                        trow.appendChild(tcell);
                    }
                    tbody.appendChild(trow);
                });
            });
}
function getQueryParameters() {
    var queryString = location.search.replace("?", "");
    var params = queryString.split("&");
    var queryParams = {};
    params.forEach(function (parm) {
        var array = parm.split("=");
        queryParams[array[0]] = array[1];
    });
   `
Answer 1

The issue is that the table is populated by javascript, but your function doesn't evaluate the javascript, it just pulls in the HTML. Check out http://phantomjs.org/ for a common solution written in Javascript. If a solution is built using the Phantom.js command line interface, you could access it from MATLAB via the system() function.

Rent Charter Buses Company
READ ALSO
Including latest jquery makes the page stop working

Including latest jquery makes the page stop working

I am working on the site where an old version of jQuery is included (1. 7.

250
Pass form data from jQuery.ajax() to SilverStripe php file for validation and email submssion

Pass form data from jQuery.ajax() to SilverStripe php file for validation and email submssion

I have built out a fairly simple html form that, once submitted, will email the contents to an email address. .

396
Flot: Threshold Failing to Show on Vertical Bar Graph

Flot: Threshold Failing to Show on Vertical Bar Graph

I am trying to add thresholds to a vertical bar graph, but for whatever reason, they are failing to appear. .

349
Insert value to database and return another value with Ajax and php

Insert value to database and return another value with Ajax and php

I'm trying to insert data to database via ajax.

341