Chapter 2. Manipulating Page Content

PhantomJS is a browser, and the basic function of a browser is to access web pages. In this chapter, we will learn various techniques of loading web pages in PhantomJS, and we will explore beyond using it simply as a headless browser.

Opening a web page

In a normal browser, opening a web page means typing a URL and letting the browser render the document fetched. It works almost the same way in PhantomJS, except that we don't actually wait for the page to be rendered before our eyes. Everything is done in a non-visual way. We don't see text, high-resolution images, or even animation on the page. We don't see anything that will show up on the screen.

We also do not type the URL in the address bar as we do in a ...

Get Getting Started with PhantomJS now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.