Simple Search on Google Images

This will retrieve a series of URL's, and send them to terminal output. These URL's are for pages that meet the search criteria "Hawaii" on Google Image Search.

import java.util.*;

import Torello.HTML.*;
import Torello.HTML.NodeSearch.*;
import Torello.Java.*;

public class GoogleImagesTest
    private static final int LEN = "".length();

    public static void main(String[] argv) throws Exception
        String urlStr = "";
        URL url = new URL(urlStr);
        Vector<HTMLNode> page = HTMLPage.getPageTokens(url, false);

        // <div class="med" id="res" role="main">
        Vector<HTMLNode> res = InnerTagGetInclusive.first(page, AVT.cmp("id", TextComparitor.EQ_CI, "res"), "div");
        System.out.println("res.size() == " + res.size());
        Vector<TagNode> anchors = TagNodeGet.all(res, TC.OpeningTags, "a");
        Vector<URL> links = Links.resolveHREFs(anchors, url);
        for (URL u : links)
            if (u != null)
                String s = Escape.replaceAll(URLs.urlToString(u).substring(LEN));
                int pos = s.indexOf("&");
                System.out.println(StringParse.setChar(s, pos, '?'));

res.size() == 365