Java Reference
In-Depth Information
URL url = new URL("http://www.httprecipes.com/1/8/menuc.php");
URLConnection http = url.openConnection();
http.setDoOutput(true);
cookies.saveCookies(http);
OutputStream os = http.getOutputStream();
// perform the post
os.write(bos.toByteArray());
// read the results
InputStream is = http.getInputStream();
ParseHTML parse = new ParseHTML(is);
// parse from the URL
advance(parse, listType, 0);
int ch;
while ((ch = parse.read()) != -1)
{
if (ch == 0)
{
HTMLTag tag = parse.getTag();
if (tag.getName().equalsIgnoreCase("li"))
{
if (buffer.length() > 0)
result.add(buffer.toString());
buffer.setLength(0);
capture = true;
} else if (tag.getName().equalsIgnoreCase("/li"))
{
result.add(buffer.toString());
buffer.setLength(0);
capture = false;
} else if (tag.getName().equalsIgnoreCase(listTypeEnd))
{
result.add(buffer.toString());
break;
}
} else
{
if (capture)
buffer.append((char) ch);
}
}
Search WWH ::




Custom Search