Sesame HTTP: Installation of PhantomJS and sesame httpphantomjs

Source: Internet
Author: User

Sesame HTTP: Installation of PhantomJS and sesame httpphantomjs

PhantomJS is an unbounded WebKit browser engine that can be programmed with scripts. It supports a variety of native Web standards: DOM operations, CSS selectors, JSON, Canvas, and SVG.

Selenium supports PhantomJS, so that no browser will pop up during running. In addition, PhantomJS is highly efficient and supports various parameter configurations for ease of use. Next, let's take a look at the installation process of PhantomJS.

1. Related Links
  • Http://phantomjs.org
  • Official documents: http://phantomjs.org/quick-start.html
  • : Http://phantomjs.org/download.html
  • API Description: http://phantomjs.org/api/command-line.html
2. Download PhantomJS

We need to download the corresponding installation package on the official website. PhantomJS supports multiple operating systems, such as Windows, Linux, Mac, and FreeBSD. we can select the corresponding platform and download the installation package.

After the download is complete, configure the path of the PhantomJS executable file to the environment variable. Environment, we need to put it directly in the path where the environment variable is configured or configure its path to the environment variable. For example, you can copy it directly to the Scripts folder of Python, or add the bin directory where it is located to the environment variable.

For configuration of environment variables in Windows, see section 1.1. For configuration of Linux and Mac environment variables, see section 1.2.3, the key is to configure the path of the executable file of PhantomJS to the environment variable.

After the configuration is successful, you can test it in the command line and enter:

phantomjs

 

 

If you can access the command line of PhantomJS, it proves that the configuration is complete, as shown in 1.

Figure 1 Console

3. Verify Installation

In Selenium, we only need to switch Chrome to PhantomJS:

from selenium import webdriverbrowser = webdriver.PhantomJS()browser.get('https://www.baidu.com')print(browser.current_url)

After running the command, we will not find any browser pop-up, but PhantomJS is actually running. Here we visited Baidu and printed the current URL.

The console output is as follows:

https://www.baidu.com/

In this way, we have completed the PhantomJS configuration, which can be used later to capture some pages.

Here we will introduce the connection methods of three mainstream browsers corresponding to Selenium. We will further explore the connection methods of Selenium and various browsers.

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.