This is the forum archive of Homey. For more information about Homey, visit the Official Homey website.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
The Homey Community has been moved to https://community.athom.com.
This forum is now read-only for archive purposes.
Can homey speak information from websites
Sigmund
Member
Hello guys!
I was wondering if anyone knows, can Homey speak specific text from websites? what I wanted to do was that I would have homey gather information from a website that tells me when my next buss leaves , and reply this information by voice or to a screen. I checked HTTP request flow cards, does this do that? Than you!
I was wondering if anyone knows, can Homey speak specific text from websites? what I wanted to do was that I would have homey gather information from a website that tells me when my next buss leaves , and reply this information by voice or to a screen. I checked HTTP request flow cards, does this do that? Than you!
Comments
Building a general app that would extract data is not that simple.
For starters take a look at readability.com
As long as the website utilizes an API it could be doable.
But you'll need an app for every website!
(in this case example.com)
//GET WEBPAGE HTML
var request = require('request');
request('http://example.com', function (error, response, body) {
if (!error && response.statusCode == 200) {
Homey.log(body) // Show the HTML.
}
Use this snippet of code to search the HTML for a word or sentence:
//DOORZOEK HTML NAAR ONDERSTAANDE
var myRegExp = /zoekwoord-moet-altijd-met-slashes-worden-genoteerd/;
var string1 = body;
var matchPos1 = string1.search(myRegExp);
if(matchPos1 != -1)
//BEPAAL POSITIE VAN ZOEKWOORD
Homey.log("There was a match at position " + matchPos1);
else
Homey.log("There was no match in the first string");
// Haal waarde op van de startpositie van myRegExp + een aantal characters
// Voorbeeld: myRegExp + 1 = m, 2 = y, 3 = R, 4 = e, 5 = g, 6 = E, 7 = x, 8 = p
var first = body.charAt((matchPos1 + 18));
var second = body.charAt((matchPos1 + 19));
var third = body.charAt((matchPos1 + 20));
var fourth = body.charAt((matchPos1 + 21));
var fifth = body.charAt((matchPos1 + 22));
var six = body.charAt((matchPos1 + 23));
var a = body.charAt((matchPos1 + 24));
var b = body.charAt((matchPos1 + 25));
var c = body.charAt((matchPos1 + 26));
http://phpjs.org/functions/strip_tags/
But it looks like his code has been cut off
(It's not working yet because the value is inserted in the HTML after homey gets the HTML)
Do whatever you want with it :-)
Give me credits and I will share more (hopefully useful) code !