Skip to content
This repository has been archived by the owner on Jan 1, 2023. It is now read-only.

Can you help me? page.type() can't use. #25

Closed
okyer opened this issue Oct 15, 2018 · 1 comment
Closed

Can you help me? page.type() can't use. #25

okyer opened this issue Oct 15, 2018 · 1 comment

Comments

@okyer
Copy link

okyer commented Oct 15, 2018

use Nesk\Puphpeteer\Puppeteer;
use Nesk\Rialto\Data\JsFunction;

require_once '../vendor/autoload.php';

$puppeteer = new Puppeteer();
$browser = $puppeteer->launch();
$page = $browser->newPage();
$response = $page->goto('http://xxgk.yichang.gov.cn/index.html');

$page->type('#vc_title', '人社局', ['delay' => 100]);
$page->click('#search_xxgk');
$page->waitFor(3000);
$dimensions = $page->evaluate(JsFunction::createWithBody("
    return {
        html: document.documentElement.outerHTML
    };
"));
file_put_contents('/tmp/search.html', $dimensions['html']);

$browser->close();

PHP Fatal error:  Uncaught Nesk\Rialto\Exceptions\Node\FatalException: Protocol error (Input.insertText): 'Input.insertText' wasn't found in /data/wwwroot/spider/vendor/nesk/rialto/src/ProcessSupervisor.php:307
Stack trace:
#0 /data/wwwroot/spider/vendor/nesk/rialto/src/ProcessSupervisor.php(387): Nesk\Rialto\ProcessSupervisor->checkProcessStatus()
#1 /data/wwwroot/spider/vendor/nesk/rialto/src/Traits/CommunicatesWithProcessSupervisor.php(83): Nesk\Rialto\ProcessSupervisor->executeInstruction(Object(Nesk\Rialto\Instruction))
#2 /data/wwwroot/spider/vendor/nesk/rialto/src/Traits/CommunicatesWithProcessSupervisor.php(91): Nesk\Rialto\Data\BasicResource->proxyAction('call', 'type', Array)
#3 /data/wwwroot/spider/demo/xxgk.php(44): Nesk\Rialto\Data\BasicResource->__call('type', Array)
#4 {main}
  thrown in /data/wwwroot/spider/vendor/nesk/rialto/src/ProcessSupervisor.php on line 307

Why is that? Can you help me, thanks.

@nesk
Copy link
Member

nesk commented Oct 23, 2018

It doesn't seem to be related to my project, this is an error occuring between Node and Chromium, not between PHP and Node. Try to write the same code but written in JS with Puppeteer, instead of PHP with PuPHPeteer. If it works in pure JS but not in PHP, I will reopen the issue.

Remember to use the Chromium executable provided by puppeteer : puppeteer/puppeteer#3396

@nesk nesk closed this as completed Oct 23, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants