Java Reference
In-Depth Information
return str.substring(location1, location2);
}
/**
* Called to process each partial page.
* @param url The URL of the partial page.
* @return Returns the next partial page, or null if no more.
* @throws IOException Thrown if an exception occurs while
* reading.
*/
public URL process(URL url) throws IOException
{
URL result = null;
StringBuilder buffer = new StringBuilder();
String value = "";
String src = "";
InputStream is = url.openStream();
ParseHTML parse = new ParseHTML(is);
boolean first = true;
int ch;
while ((ch = parse.read()) != -1)
{
if (ch == 0)
{
HTMLTag tag = parse.getTag();
if (tag.getName().equalsIgnoreCase("a"))
{
buffer.setLength(0);
value = tag.getAttributeValue("href");
URL u = new URL(url, value.toString());
value = u.toString();
src = null;
} else if (tag.getName().equalsIgnoreCase("img"))
{
src = tag.getAttributeValue("src");
} else if (tag.getName().equalsIgnoreCase("/a"))
{
if (buffer.toString().equalsIgnoreCase("[Next 5]"))
{
result = new URL(url, value);
} else if (src != null)
{
if (!first)
Search WWH ::




Custom Search