Java Reference
In-Depth Information
}
}
return false;
}
/**
* Handle each list item, as it is found.
* @param item The item to be processed.
*/
private void processItem(String item)
{
System.out.println(item.trim());
}
/**
* Access the website and perform a search for either
* states or capitals.
* @param search A search string.
* @param type What to search for(s=state, c=capital)
* @throws IOException Thrown if an IO exception occurs.
*/
public void process(String search, String type)
throws IOException
{
String listType = "ul";
String listTypeEnd = "/ul";
StringBuilder buffer = new StringBuilder();
boolean capture = false;
// build the URL
ByteArrayOutputStream bos = new ByteArrayOutputStream();
FormUtility form = new FormUtility(bos, null);
form.add("search", search);
form.add("type", type);
form.add("action", "Search");
form.complete();
String surl = "http://www.httprecipes.com/1/7/get.php?" +
bos.toString();
URL url = new URL(surl);
InputStream is = url.openStream();
ParseHTML parse = new ParseHTML(is);
// parse from the URL
advance(parse, listType, 0);
Search WWH ::




Custom Search