Hi Cerebrus,

1.  Sorry for the code not compiling.
2. Thanks for the reply.I think you have given me a hint ,to proceed further
which i will try.

Thanks
Pratiksha
(M) 9999774442


On Wed, Jul 7, 2010 at 10:46 PM, Cerebrus <[email protected]> wrote:

> Pratiksha:
>
> 1. The code you have posted does not even compile.
>
> 2. We expect members to post long-ish code sections at
> dotnetdevelopment.pastebin.com, so that code can be read and
> understood.
>
> 3. What you are trying to do is known as "Scraping". The NDNC does not
> expose this page as a public API / webservice to be subscribed by you,
> so you have to understand how the page works. For that you have to
> analyze the inner workings of the page. Since I have (too much)
> experience in scraping, I was able to modify the code to successfully
> scrape it in about 5 min. But I am not going to give you the code
> because you will learn nothing in the process.
>
> I will however give you some hints:
> a) You need to search for the form action (in the page source -
> Javascript section) and post your data to that URL.
> b) Form values are always posted as a "name=value(s)" setting. In this
> case, the postData variable would be written as :
> ---
> string phoneToCheck = "9999774442";
> string postData = "phoneno=" + phoneToCheck;
> ...
> ...
> ---
>
> HTH,
>
> Cerebrus.
>
>
>
> On Jul 7, 3:37 pm, Pratiksha Saxena <[email protected]>
> wrote:
> > Hi,
> >
> > I want to post data tohttp://
> ndncregistry.gov.in/ndncregistry/search.miscinWindow
> > Application
> >
> > It checks if phone no is registered with particular website.
> >
> > So i wrote the following code.(*Webbrowser is not to be used -According
> to
> > requirement)*
> >
> > But it is not working.Can somebody help me.
> > *
> >
> >  private void button3_Click(object sender, EventArgs e)
> > {
> >            string postData = "9999774442";
> >
> >             ASCIIEncoding encoding = new ASCIIEncoding();
> >             //string postData =  strId;
> >
> >             byte[] data = encoding.GetBytes(postData);
> >
> >             // Prepare web request...
> >             try
> >             {
> >                 HttpWebRequest myRequest =
> >                   (HttpWebRequest)WebRequest.Create("
> http://ndncregistry.gov.in/ndncregistry/search.misc";);
> >                 myRequest.Method = "POST";
> >                 myRequest.ContentType =
> "application/x-www-form-urlencoded";
> >                 myRequest.ContentLength = data.Length;
> >                 Stream newStream = myRequest.GetRequestStream();
> >                 // Send the data.
> >                 newStream.Write(data, 0, data.Length);
> >                 newStream.Close();
> >             }
> >             catch (Exception ex)
> >             {
> >             }
> >
> >            String post_response;
> >            HttpWebResponse objResponse =
> > (HttpWebResponse)myRequest.GetResponse();
> >            using (StreamReader responseStream = new
> > StreamReader(objResponse.GetResponseStream()))
> >            {
> >                post_response = responseStream.ReadToEnd();
> >                responseStream.Close();
> >            }
> >
> > }
> >
> > Thanks
> > Pratiksha
> > (M) 9999774442
> > *

Reply via email to