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. Let's take a look at the installation process for PHANTOMJS.
1. RELATED LINKS
- 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
2. Download Phantomjs
We need to download the corresponding installation package on the official website, PHANTOMJS support various operating systems, such as Windows, Linux, Mac, FreeBSD, etc., we can select the corresponding platform and download the installation package.
When the download is complete, configure the path where the PHANTOMJS executable is located in the environment variable. For example, under Windows, the downloaded files are unpacked and opened, you will see a bin folder, which includes an executable file Phantomjs.exe, we need to put it directly in the configuration of the environment variable path or the path it is located in the environment variable. For example, we can either copy it directly to the Python Scripts folder or add the bin directory where it resides to the environment variable.
The configuration of environment variables under Windows can be found in section 1.1, and the configuration of Linux and MAC environment variables can be found in section 1.2.3, where the key is to configure the path of the PHANTOMJS executable to the environment variable.
After the configuration is successful, you can test it at the command line and enter:
Phantomjs
If you can go to the PHANTOMJS command line, it proves that the configuration is complete, as shown in 1.
Figure 1 Console
3. Verifying the Installation
For use in selenium, we just need to switch chrome to PHANTOMJS:
from = 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/
As a result, we have completed the PHANTOMJS configuration, which can be used to complete some page crawl.
Here we introduce the selenium corresponding to the three major mainstream browser docking method, we will be selenium and each browser docking methods for more in-depth exploration.
Installation of Sesame Http:phantomjs