PHANTOMJS is a non-interface, scriptable WebKit browser engine that natively supports a variety of Web standards: DOM manipulation, CSS selectors, JSON, canvas, and SVG.
Selenium supports PHANTOMJS, so it won't pop up a browser when it's running. Moreover, the operation efficiency of PHANTOMJS is also very high, it also supports various parameter configurations and is very convenient to use.
First, install the PHANTOMJS
Official website: http://phantomjs.org
Official Document: Http://phantomjs.org/quick-start.html
: http://phantomjs.org/download.html
API Interface Description: http://phantomjs.org/api/command-line.html
When the download is complete, configure the path where the PHANTOMJS executable is located in the environment variable.
For use in selenium, we just need to switch chrome to PHANTOMJS:
From selenium import Webdriverbrowser = Webdriver. PHANTOMJS () browser.get (' https://www.baidu.com ') print (Browser.current_url)
After running, we will not find a browser pop-up, but actually PHANTOMJS is already running. Here we visit Baidu, and then print out the current URL.
The output of the console is as follows:
https://www.baidu.com/
Installation and use of PHANTOMJS