Java Reference
In-Depth Information
}
/*
* Handle each list item, as it is found.
*/
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 and POST
URL url = new URL("http://www.httprecipes.com/1/7/post.php");
URLConnection http = url.openConnection();
http.setDoOutput(true);
OutputStream os = http.getOutputStream();
FormUtility form = new FormUtility(os, null);
form.add("search", search);
form.add("type", type);
form.add("action", "Search");
form.complete();
// read the results
InputStream is = http.getInputStream();
ParseHTML parse = new ParseHTML(is);
// parse from the URL
advance(parse, listType, 0);
int ch;
Search WWH ::




Custom Search