These are chat archives for rosshinkley/nightmare

22nd
Jun 2016
Mingsterism
@mingsterism
Jun 22 2016 01:24
hey guys. is it possible to run proxy ip rotation with nightmare js.
gatsbylee
@gatsbylee
Jun 22 2016 01:24
@mingsterism what do you mean?
Mingsterism
@mingsterism
Jun 22 2016 01:24
when mining from a site, constantly change ip on a regular basis.
btw, was thinking do you guys want to collaborate and share scripts on nightmarejs. that way we each can learn from each other and make using nightmare a more pleasurable experience
Mingsterism
@mingsterism
Jun 22 2016 01:30
something like a cookbook with nightmarejs. @rosshinkley is that a good idea?
Ross Hinkley
@rosshinkley
Jun 22 2016 01:30
@sammyyu hm, i'm not sure there's a way to get that information from electron
switches can be set, but it doesn't look like there's a quick way to check current settings
@mingsterism there are certainly proxy options with the proxy-server switch
but if you're asking if you can rotate your IP locally, the answer is probably no
re the cookbook idea... i started throwing such a thing together
Ross Hinkley
@rosshinkley
Jun 22 2016 01:35
Sammy Yu
@sammyyu
Jun 22 2016 01:36
@rosshinkley thanks so much for the help! Is it correct to assume that all the options listed here: http://peter.sh/experiments/chromium-command-line-switches/ can be passed through as Nightmare(switches:). ie: there is no hard coding of limiting only certain command line switches?
Ross Hinkley
@rosshinkley
Jun 22 2016 01:36
it's kind of lean, but i've been trying to set aside time here and there to pick away at examples
@sammyyu no problem, i apologize what i said probably isn't all that helpful :P
i'll take another look in a minute, entirely possible there's something i don't know about with app.commandLine
Sammy Yu
@sammyyu
Jun 22 2016 01:38
@rosshinkley sweet thanks!
Ross Hinkley
@rosshinkley
Jun 22 2016 01:39
and answering your question, if i understand correctly, you're right - there are some default values Nightmare props up for Electron switches (eg, hiding the window by default), but everything is settable/overrideable
Sammy Yu
@sammyyu
Jun 22 2016 01:41
@rosshinkley perfect!
Ross Hinkley
@rosshinkley
Jun 22 2016 01:42
go nuts :)
Mingsterism
@mingsterism
Jun 22 2016 01:43
@rosshinkley thanks ross. will check out proxy-server. yeah been reading nightmare examples. its pretty good. just wondering if there were more people contributing to it.
Sammy Yu
@sammyyu
Jun 22 2016 01:44
@rosshinkley btw nightmare is amazing, thanks for making it open source
Ross Hinkley
@rosshinkley
Jun 22 2016 01:44
@sammyyu i wish i had something to do with electron :P
Sammy Yu
@sammyyu
Jun 22 2016 01:44
both are amazing :)
Ross Hinkley
@rosshinkley
Jun 22 2016 01:45
and nightmare isn't mine either, i'm just the help
but i understand the sentiment :)
Sammy Yu
@sammyyu
Jun 22 2016 01:46
heh
Ross Hinkley
@rosshinkley
Jun 22 2016 01:46
@mingsterism yyyeah, it should pick up traction now that it's linked in the readme
what i ought to do is set aside an evening a week to do more with that
but... it hasn't panned out :|
Mingsterism
@mingsterism
Jun 22 2016 04:39
@rosshinkley ross. i cant seem to get this to work. I have an external function outsite of nightmare scope. I tried this, but it does not work.
.then(function() {
        return nightmare
            .evaluate(function() {
                console.log(nextPage)
                if (nextPage) {
                    return nextPage
                }
                else {
                    return nightmare.end()
                }
            })
        })
however, this does
nightmare
  .goto('url')
  .evaluate(externalFn)
  .then()
i basically want to paginate to the next page, and i have a function nextPage then checks the current window for nextPage. if True, then go next page. Else nightmare.end()
Ross Hinkley
@rosshinkley
Jun 22 2016 15:25
@mingsterism you're trying to run nightmare methods inside of an evaluate... that's not going to work
Mingsterism
@mingsterism
Jun 22 2016 15:30
@rosshinkley so you mean this is where the problem is at?
else {
    return nightmare.end()
}
Ross Hinkley
@rosshinkley
Jun 22 2016 15:30
yeah, .evaluate() runs javascript as though it were run by the site
Mingsterism
@mingsterism
Jun 22 2016 15:31
any thoughts on how could the if statement could be implemented. I'm assuming its within the then function?
Ross Hinkley
@rosshinkley
Jun 22 2016 15:31
uh, off the cuff
.then(function() {
  return nightmare
    .evaluate(function() {
      var nextPage = doSomethingToGetNextPage();
        return nextPage;
      })
    })
     .then(function(nextPage){
        if(nextPage) { 
          // ... whatever action you need to do....
       } else {
          return nightmare.end();
       }
     })
     .then(function() { ...
jeez, formatting turned out terrible
but... should get the idea across
Mingsterism
@mingsterism
Jun 22 2016 23:45
@rosshinkley thanks Ross. Will give that a try.