shinoshi / nightmare-php
此包已被放弃,不再维护。未建议替代包。
nightmareJS 的 PHP 封装器
0.9.5
2017-11-26 16:23 UTC
Requires (Dev)
- symfony/var-dumper: ^3.3
This package is not auto-updated.
Last update: 2022-04-10 20:14:07 UTC
README
PHP 封装器为 NightmareJS
使用方法
原始选项(推荐)
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
预定义方法选项
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
预定义方法选项可能不包括 nightmareJS 提供的所有最新选项,相关文档可以在他们的官方 github 仓库 找到