shinoshi / nightmare-php
PHP wrapper for nightmareJS
Installs: 8 411
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 1
pkg:composer/shinoshi/nightmare-php
Requires (Dev)
- symfony/var-dumper: ^3.3
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