Java Reference
In-Depth Information
The above code locates token2 using indexOf . If the second token is not found,
then null is returned to indicate an error. Otherwise substring is called to return
the text between the two tokens. It is important to remember to add the length of token1
to location1 . If you do not add this to location1 , you will extract token1 along
with the desired text.
This recipe can be applied to any real-world site that contains data on a single page that
you wish to extract. Although this recipe extracted information from the web page, it did not
do anything with it. The next recipe will actually process the downloaded data.
Recipe #3.3: Parsing Dates and Times
This recipe shows how to extract data from several pages. It also shows how to parse date
and time information. This recipe will download the date and time for several US cities. It will
extract this data from the following URL:
http://www.httprecipes.com/1/3/cities.php
Figure 3.3 shows this web page.
Figure 3.3: Cities for which to Display Time
Search WWH ::




Custom Search