Java Reference
In-Depth Information
/**
* The main method, create a new instance of the object and call
* process.
* @param args not used.
*/
public static void main(String args[])
{
try
{
DownloadArticle parse = new DownloadArticle();
parse.process();
} catch (Exception e)
{
e.printStackTrace();
}
}
}
This recipe is structured around two functions. The first function, named process , reads
the automatic choice list and extracts URLs from it. These URLs will be the URLs for all of the
pages in the article. Next, the process method calls the downloadArticlePage
method for each URL extracted.
The next two sections will describe these two functions. First, we will examine the
process function.
Reading the Choice List
The process function reads the <option> tags that will be passed to the Java-
Script. This will give us a complete list of where all seven pages are stored. You can see the
option tags that we will be parsing here:
<option SELECTED VALUE="/1/9/article.php?id=1">
Page 1 - Introduction</option>
<option VALUE="/1/9/article.php?id=2">
Page 2 - Using the BinaryFile Class</option>
<option VALUE="/1/9/article.php?id=3">
Page 3 - String Datatypes</option>
<option VALUE="/1/9/article.php?id=4">
Page 4 - Numeric Datatypes</option>
<option VALUE="/1/9/article.php?id=5">
Page 5 - Alignment</option>
<option VALUE="/1/9/article.php?id=6">
Page 6 - Reading a GIF Header</option>
<option VALUE="/1/9/article.php?id=7">
Page 7 - Summary</option>
Search WWH ::




Custom Search