# Address Book Import

**URL:** <https://www.ruby-forum.com/t/address-book-import/113275>\
**Category:** Rails\
**Created:** [August 29, 2007, 2:24pm UTC](https://www.ruby-forum.com/t/address-book-import/113275 "2007-08-29T14:24:23Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![pradeep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f0a364/32.png) [@pradeep](https://www.ruby-forum.com/u/pradeep)\
**Post date:** [August 29, 2007, 2:24pm UTC](https://www.ruby-forum.com/t/address-book-import/113275/1 "2007-08-29T14:24:23Z")

</div>

Hi All,

Is there any way to import address book of rediffmail and indiatimes  
using ruby. Please let me know the details.

Thanks in Advance

Regards,

Pradeep

---

<div class="post-metadata">

**Author:** ![pradeep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f0a364/32.png) [@pradeep](https://www.ruby-forum.com/u/pradeep)\
**Post date:** [May 16, 2008, 6:30am UTC](https://www.ruby-forum.com/t/address-book-import/113275/2 "2008-05-16T06:30:15Z")

</div>

Hello friends,

i am working on a task that “Import Address Book from [indiatimes.com](http://indiatimes.com) in  
c#.”

in this module, i solved the login process, but i cannot get the  
contact.csv file.

can u tell me

here is my code

string strLoginUrl =  
“[http://integra.indiatimes.com/Times/Logon.aspx?ru=](http://integra.indiatimes.com/Times/Logon.aspx?ru=)” +  
HttpContext.Current.Server.UrlEncode(“[http://infinite.indiatimes.com/cgi-bin/gateway](http://infinite.indiatimes.com/cgi-bin/gateway)”)  
+  
“&IS=058f3c27-6793-41c7-a676-81e3f3594a5c&NS=email&HS=kSVLJ96CWWzEmTwPZa1LD6YR7NM=”;  
string strLoginUrlPost = “op=login&login=” + strUserid + “&passwd=” +  
strPassword + “&rememberme=&rememberPwd=&Sign+In=”;  
HttpWebRequest webReqLogin =  
(HttpWebRequest)WebRequest.Create(strLoginUrl);  
webReqLogin.Method = Utility.Post;  
webReqLogin.UserAgent =  
HttpContext.Current.Request.ServerVariables[“HTTP\_USER\_AGENT”];  
webReqLogin.KeepAlive = true;  
webReqLogin.AllowAutoRedirect = false;  
webReqLogin.UseDefaultCredentials = true;  
webReqLogin.CookieContainer = new CookieContainer();  
webReqLogin.ContentLength = strLoginUrlPost.Length;  
webReqLogin.ContentType=“application/x-www-form-urlencoded”;

StreamWriter sw = new StreamWriter(webReqLogin.GetRequestStream(),  
System.Text.Encoding.ASCII);  
sw.Write(strLoginUrlPost); sw.Close();  
HttpWebResponse webResLogin =  
(HttpWebResponse)webReqLogin.GetResponse();

webResLogin.Cookies =  
webReqLogin.CookieContainer.GetCookies(webReqLogin.RequestUri);

//string strNewResponseUrl = webResLogin.StatusDescription;

StreamReader sr = new  
StreamReader(webReqLogin.GetResponse().GetResponseStream());  
String strMainPage = sr.ReadToEnd();  
sr.Close();

CookieCollection ccWebReqLogin = new CookieCollection();  
ccWebReqLogin.Add(webResLogin.Cookies);  
[//webResLogin.Close](https://webResLogin.Close)();  
[//webReqLogin.Abort](https://webReqLogin.Abort)();

string strAddressBookRequestUrl = webResLogin.ResponseUri.ToString();  
string strAddressBookRefererUrl =  
“[http://tilmb19.indiatimes.com/h/search?st=contact](http://tilmb19.indiatimes.com/h/search?st=contact)”;  
//2========================================================================================  
HttpWebRequest webReqAddress =  
(HttpWebRequest)WebRequest.Create(strAddressBookRequestUrl);

webReqAddress.Method = Utility.Get;  
webReqAddress.UserAgent =  
HttpContext.Current.Request.ServerVariables[“HTTP\_USER\_AGENT”];  
webReqAddress.Referer = webResLogin.ResponseUri.ToString();  
webReqAddress.CookieContainer = new CookieContainer();  
webReqAddress.CookieContainer.Add(ccWebReqLogin);

HttpWebResponse webResAddress =  
(HttpWebResponse)webReqAddress.GetResponse();  
webResAddress.Cookies =  
webReqAddress.CookieContainer.GetCookies(webReqAddress.RequestUri);

StreamReader sr2 = new StreamReader(webResAddress.GetResponseStream());  
string strAddressXml = sr2.ReadToEnd();  
if (strAddressXml == string.Empty)  
{  
boolIsOK = false;  
strError = Utility.ApplicationError;  
return;  
}  
sr2.Close();  
[//webResAddress.Close](https://webResAddress.Close)();  
[//webReqAddress.Abort](https://webReqAddress.Abort)();

CookieCollection ccWebReqLogin2 = new CookieCollection();  
ccWebReqLogin2.Add(webResAddress.Cookies);

strAddressBookRequestUrl = “[http://tilmb19.indiatimes.com](http://tilmb19.indiatimes.com)”;  
strAddressBookRefererUrl =  
“[http://tilmb19.indiatimes.com/h/search?st=contact](http://tilmb19.indiatimes.com/h/search?st=contact)”;  
//2========================================================================================  
HttpWebRequest webReqAddress2 =  
(HttpWebRequest)WebRequest.Create(strAddressBookRequestUrl);

webReqAddress2.UserAgent =  
HttpContext.Current.Request.ServerVariables[“HTTP\_USER\_AGENT”];  
webReqAddress2.Referer = webResAddress.ResponseUri.ToString();  
webReqAddress2.CookieContainer = new CookieContainer();  
webReqAddress2.ContentType = “application/x-www-form-urlencoded”;

webReqAddress2.CookieContainer.Add(ccWebReqLogin);  
webReqAddress2.CookieContainer.Add(ccWebReqLogin2);

webReqAddress2.AllowAutoRedirect = true;

StreamReader sr21 = new  
StreamReader(webReqAddress2.GetResponse().GetResponseStream());  
strAddressXml = sr21.ReadToEnd();  
if (strAddressXml == string.Empty)  
{  
boolIsOK = false;  
strError = Utility.ApplicationError;  
return;  
}  
sr21.Close();  
webReqAddress2.Abort();

Kamal Jindal  
+91 999 110 1929

Pradeep wrote:

> Hi All,
> 
> Is there any way to import address book of rediffmail and indiatimes  
> using ruby. Please let me know the details.
> 
> Thanks in Advance
> 
> Regards,
> 
> Pradeep

---

<div class="post-metadata">

**Author:** ![pradeep](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f0a364/32.png) [@pradeep](https://www.ruby-forum.com/u/pradeep)\
**Post date:** [May 16, 2008, 11:30am UTC](https://www.ruby-forum.com/t/address-book-import/113275/3 "2008-05-16T11:30:01Z")

</div>

On 16 May 2008, at 05:30, Kamal Jindal wrote:

> Hello friends,
> 
> i am working on a task that “Import Address Book from [indiatimes.com](http://indiatimes.com)  
> in  
> c#.”
> 
> in this module, i solved the login process, but i cannot get the  
> contact.csv file.

Why are you chucking some C# code at a ruby on rails group ?

Fred
