Skip to content

dioro/nightmarePHP

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

28 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NightmarePHP

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

About

PHP wrapper for nightmarejs

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages