shinoshi/nightmare-php

This package is abandoned and no longer maintained. No replacement package was suggested.

PHP wrapper for nightmareJS

0.9.5 2017-11-26 16:23 UTC

This package is not auto-updated.

Last update: 2022-04-10 20:14:07 UTC


README

PHP wrapper for NightmareJS

Usage

Raw option (recommended):

use dioro\nightmarePHP\nightmarePHP;

$nightmare = new nightmarePHP();

$nightmare->rawInput("
const Nightmare = require(\"nightmare\");
const nightmare = Nightmare({ show: false });

nightmare
    .goto('https://www.reddit.com/r/news/')
    .wait('#siteTable > div:first-child .title > a')
    .evaluate(() => document.querySelector(\"#siteTable > div:first-child .title > a\").textContent)
.end()
    .then(console.log)
    .catch((error) => {console.error('Search failed:', error);});")
    ->run();

var_dump($nightmare->getResult()); #returns latest title of the /r/news subreddit

Predefined method option:

use dioro\nightmarePHP\nightmarePHP;

$nightmare = new nightmarePHP();

$nightmare->config("show: false");

$nightmare
->_goto('https://www.reddit.com/r/news/')
->wait('#siteTable > div:first-child .title > a')
->evaluate("() => document.querySelector(\"#siteTable > div:first-child .title > a\").textContent")
->end()
->then("console.log")
->_catch("(error) => {console.error('Search failed:', error);}")
->run();

var_dump($nightmare->getResult()); #returns latest title of the /r/news subreddit

Predefined method option may not include all up to date options that NightmareJS offers to which the documentation can be found their official github repo