Objective
Phantomjs is a browser with no interface, essentially it is actually a browser, but not on the interface display.
PHANTOMJS is perfect for crawlers, and many crawlers like to use this browser.
First, PHANTOMJS environment preparation
1. Download the Phantomjs browser first: http://phantomjs.org/download.html
2. Extract it after download, locate the Phantomjs.exe file under the Phantomjs-2.1.1-windows\bin folder, and place it in the root directory of Python
Second, run the code
1. Launch Phantomjs Browser: Webdriver. PHANTOMJS ()
2. After running, the computer screen will not appear on the browser, you can see the print log, and then know whether the operation is successful
3. After running, a log file will be generated in the current folder, open to view the log information
Third, the reference code:
# Coding:utf-8
From selenium import Webdriver
Import time
Driver = Webdriver. PHANTOMJS ()
Driver.get ("https://www.baidu.com")
driver.find_element_by_id ("kw"). Send_keys ("Yoyo")
driver.find_element_by_id ("su"). Click ()
Time.sleep (2)
Print Driver.title
Selenium2+python Automation 69-PHANTOMJS Use "reprint"