public String[] getURLs()
{
String q = “declare namespace xhtml=\”http://www.w3.org/1999/xhtml\”; \n” +
”for $d in //xhtml:ol[@id=’abcnav’]/xhtml:li/xhtml:a \n”+
” return
//pScrape is a com.apsquared.jscrape.PageScraper object that has already logged in to the site.
List l = pScrape.scrapePageForList(“http://address.yahoo.com/yab/us”, q);
if (l == null)
return null;
String[] ret = new String[l.size()];
for (int i = 0; i < l.size() ; i++)
{
TinyNodeImpl ti = (TinyNodeImpl)l.get(i);
ret[i] = new String(ti.getStringValue());
}
return ret;
}
Note: this may return null if the user account only has a small # of contacts.
For each url returned you need to scrape the page looking for the contacts. I used the following XQuery for that scrape:
declare namespace xhtml=\”http://www.w3.org/1999/xhtml\”;
for $d in //xhtml:td[@class=’contactnumbers’]/xhtml:span/xhtml:a
return
That’s about it, as we’ll see in the next few days this is much simpler than many other sites (GMail, Hotmail, AOL) as they require many more tricks to login.