📜  PhantomJS-网页模块属性

📅  最后修改于: 2020-10-21 05:34:52             🧑  作者: Mango


PhantomJS提供了很多属性和方法来帮助我们与网页内的内容进行交互。

require(“ webpage”)。create()命令创建一个网页对象。我们将使用此对象在下面列出的属性和方法的帮助下操纵网页。

var wpage = require("webpage").create();

下表列出了我们将要讨论的所有网页属性。

S.No Properties & Description
1 canGoBack

This property returns true if there is previous page in the navigation history; if not, false.

2 canGoForward

This property returns true if there is next page in the navigation history; if not, false.

3 clipRect

clipRect is an object with values top, left, width and height and used to take the image capture of the webpage when used by the render() method.

4 Content

This property contains the contents of webpage.

5 cookies

With cookies, you can set /get the cookies available on the URL. It will also give you the cookies available on the URL and the new cookies set on the page.

6 customHeaders

customHeaders specifies additional HTTP request headers that will be send to server for every request issued by the page.

7 Event

It gives long list of events i.e. modifier, keys details.

8 focusedFrameName

Returns the name of the currently focused frame.

9 frameContent

This property gives the content of the frame which is active.

10 frameName

Returns the name of the currently focused frame.

11 framePlainText

This property also gives the contents of the current active frame but only contents without any html tags.

12 frameTitle

Gives the title of the active frame.

13 frameUrl

This property will give the url of the currently focused frame.

14 framesCount

Gives the count of the frames present on the page.

15 framesName

Gives array of frame names.

16 libraryPath

This property has the path, which is used by page.inectJs method.

17 navigationLocked

This property defines whether navigation of the page is allowed or not. If true it will be on current page url and clicking on page to go to next page will not be allowed.

18 offlineStoragePath

This property gives the path where the data is stored using window.localStorage.The path can be changed using –local-storage-path from command line.

19 offlineStorageQuota

This property defines the maximum amount of data you can store in window.localStorage.The value is 5242880 bytes which is 5MB.This value can overwritten at command line using the following command –localstorage-quota = size over here.

20 ownsPages

ownsPages returns true or false if the page opened by the webpage is a child of the webpage.

21 pagesWindowName

PagesWindowName will give the names of the windows open using window.open

22 pages

The pages property will you give array of pages opened in a page using window.open. If the page is closed in url you referring the page will not be considered.

23 paperSize

This property gives the size ie dimensions of the webpage when needs to be used to convert the webpage in a pdf format.paperSize contains the dimensions required in an object.

24 plaintext

This property also gives the contents of the current active frame but only contents without any html tags.

25 scrollPosition

This contains object indicating the scroll position. It gives left and top.

26 settings

This property will give the settings of the webpage when page.open method is used. Once the page is loaded the changes in settings properties will not create any impact.

27 title

This property will give you the title of the page you are reading.

28 url

This property will give the page url.

29 viewportSize

This property allows to change the size of the window display. It contains width and height, which you can read or change it as per the needs.

30 windowName

Gives the name of the window.

31 zoomFactor

This property specifies the zoom factor for render and renderBase64 methods. It helps to zoom a page and take a screen capture if required.