Retrieving Web Pages

Explicit Specification of a Page URL

The very first step in any interaction with a web site is to obtain a start page. To do this, we create a WebConversation object to play the role of the web browser. This object will store browser state such a cookies, windows, and so on. We then ask for the page by specifying the desired URL:

WebConversation wc = new WebConversation();
WebResponse wr = wc.getResponse( "http://www.meterware.com" );
System.out.println( wr.getText() );
This example will simply print out the text of the retrieved page. Obviously, given this text, it is easy to search for particular strings on the page, if that is desired.