Selenium2+python Automation 69-PHANTOMJS Use "reprint"

Source: Internet
Author: User

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"

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.