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.

Can homey speak information from websites

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!

Comments

  • There is a wikipedia app .
    Building a general app that would extract data is not that simple.

    For starters take a look at readability.com
  • The Wikipedia app uses a specific call through the API.
    As long as the website utilizes an API it could be doable.
    But you'll need an app for every website!
  • edited April 2016
    I use this snippet to extract the HTML from a specific webpage:
    (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));
  • I would use the method of @MathijsFrencken to load html, start at specific keyword and then stripping all tags:
    http://phpjs.org/functions/strip_tags/
    But it looks like his code has been cut off :)

  • ok, thanks guys for the great information. I will look into this and let you know if i manage to do this :)
  • I would use the method of @MathijsFrencken to load html, start at specific keyword and then stripping all tags:
    http://phpjs.org/functions/strip_tags/
    But it looks like his code has been cut off

    Im sorry, here is the full project I was working on: an app that tracks your dominos pizza order and makes homey say "Pizza is on its way", "Pizza is in the oven", "Pizza is being made"   etc by getting an increasing value from the order page.

    (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 !
  • If the status gets inserted after the loading html, it gets a status through json / javascipt? Can you fetch this json-call?
  • If the status gets inserted after the loading html, it gets a status through json / javascipt? Can you fetch this json-call?
    Maybe, it does get inserted after the html loads but I can only see it get inserted in the html when actually ordering a pizza, might do in a couple of days.
Sign In or Register to comment.