PHP controls browser actions

PHPz
Release: 2023-03-07 10:24:01
Original
2800 people have browsed it

System environment:

  • Mac

Principle:

  • 1: Use phpLanguage writing control script

  • 2: The script communicates with the chrome driver (chromedriver) program

  • 3: chromedriver controls chrome execution operations

Process: php script => chromedriver => chrome

Software needed

##Operation Demo

  • 1:

    Installationphp-webdriver Create a demo directory and execute
    composer require facebook/webdriver

  • 2: Download chromedriver, double-click to run

  • 3: In the demo directory, create the demo.php file

get('http://www.baidu.com');

$cookies = $driver->manage()->getCookies();
print_r($cookies);


echo "The title is '" . $driver->getTitle() . "'\n";
echo "The current URI is '" . $driver->getCurrentURL() . "'\n";

//关闭浏览器
$driver->quit();
Copy after login
  • 4: Run demo.php


    php demo.php

The above is the detailed content of PHP controls browser actions. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!