johntitus / node-horseman

Run PhantomJS from Node

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Some sort of persistence - reading new values every 1 second?

prabab opened this issue · comments

Sorry if I'm misunderstanding some basic concepts behind Horseman, but is it possible to somehow open a page and leave it open for, for example, 5 minutes, and during this time read and return new values from a specific field (which is updated by on-site javascript) every 1 second or so? The only way this is presented in examples (the Twitter one) is to reopen the page each time I want to read something, but that would murder my data transfer if I had to re-download the whole page every single time.

The page is open and the scripts on it are running. You just have to wait a while and then get the value again using horseman.

horseman.open(someUrl)
    .then(function poll() {
        return this.value(someSelector)
            .then(value => {
                // do some with value
            })
            .delay(10000) // wait 1 second
            .then(poll);
    })