Java Code to scrape a hotmail address book
Hi all... Can anyone help with trying to scrape a hotmail address book based on the user-id and password given with the help of a java program.. I tried using HTML Unit to do this but the process seems too tedious.. and cant really figure out the hidden variables n stuff in the hotmail website.
Please help me out.... !! thanx !!
[343 byte] By [
jlexjoya] at [2007-11-27 11:19:55]

# 3
Yes i did try that though... But it didnt work... I've made use of HTMLUnit to do this .. I've extracted all the hidden variables and tried to re-post them.. But still wasnt able to sign in to Hotmail through Java.. Here's the code that i tried...
String PwdPad="IfYouAreReadingThisYouHaveTooMuchFreeTime";
final WebClient webClient=new WebClient(BrowserVersion.INTERNET_EXPLORER_6_0);
webClient.setRedirectEnabled(true);
//Get the hotmail page
final URL url=new URL("http://www.hotmail.com");
HtmlPage homePage=null;
homePage=(HtmlPage)webClient.getPage(url);
Search(homePage);
final HtmlForm form=homePage.getFormByName("f1");
final HtmlSubmitInput button=(HtmlSubmitInput) form.getInputByName("SI");
//Settting the user name and password
final HtmlTextInput text1=(HtmlTextInput) form.getInputByName("login");
final HtmlPasswordInput text2=(HtmlPasswordInput) form.getInputByName("passwd");
//Hidden Variables
final HtmlHiddenInput ppsx=(HtmlHiddenInput) form.getInputByName("PPSX");
final HtmlHiddenInput pwdpad=(HtmlHiddenInput) form.getInputByName("PwdPad");
final HtmlHiddenInput ppft=(HtmlHiddenInput) form.getInputByName("PPFT");
System.out.println("The Action is:: "+form.getActionAttribute());
//Re-posting the Entries (PPSX,Login,Password,PwdPad,PPFT)
int len;
len=PwdPad.length()-pass.length();
PwdPad = PwdPad.substring(0, len);
text1.setValueAttribute(email);
text2.setValueAttribute(pass);
//ppsx.setValueAttribute( ppsx.getValueAttribute());
//pwdpad.setValueAttribute( PwdPad);
//ppft.setValueAttribute( ppft.getValueAttribute());
System.out.println("user:"+text1.getValueAttribute() + "password:" + pass+"ppsx:"+ppsx.getValueAttribute()+"PwdPad:"+pwdpad.getValueAttribute()+"ppft:"+ppft.getValueAttribute() + " login opts:");
//URL postURL = new URL ("https://login.live.com/ppsecure/post.srf?id=2&bk=1185180903") ;
URL postURL = new URL (form.getActionAttribute()) ;
WebRequestSettings webRequestSettings = new WebRequestSettings(postURL,SubmitMethod.POST);
String requestBody = "PPSX="+ ppsx.getValueAttribute() +"&PwdPad="+PwdPad+"&login=email%40hotmail.com&passwd="+pass+
"&LoginOptions=2&PPFT=" + ppft.getValueAttribute() ;
webRequestSettings.setRequestBody(requestBody);
//HtmlPage page= ( HtmlPage ) webClient.getPage(webRequestSettings);
HtmlPage page=(HtmlPage)button.click();
System.out.println(page.asText());