Hi everyone! Now i started to use magicMirror and want to build my simple custom module to indncate somrthing (traffic load at now).
I wrote a scrypt
var text1 = "";
var text2 = "";
var text3 = "";
var htmlpage = 'https://www.yandex.ru';
var request = require('request');
var DomParser = require('dom-parser');
var parser = new DomParser();
var dom;
setInterval(function() {
request(htmlpage, function(error, response, body) {
dom = parser.parseFromString(body);
text1 = dom.getElementsByClassName('traffic i-bem')[0].innerHTML;
dom = parser.parseFromString(text1);
text2 = dom.getElementsByTagName('H1')[0].innerHTML;
dom = parser.parseFromString(text2);
text3 = dom.getElementsByClassName('link link_black_yes')[0].textContent });
}, 1000);
request and dom-parser eas intalled.
Then i get text data string and i want to set it into the Hello world module next.
I added my scrypt code into the module code here:
getDom: function() {
var wrapper = document.createElement("div");
wrapper.innerHTML = this.config.text;
return wrapper;
}
But it doesnt work (request and parser modules). Otherwise, just counting number works well(((.
Could not you help me, what i have to do to get my scrypt working inside helloworld module?