This project has moved and is read-only. For the latest updates, please go here.

how to get table from another website with method=post

Topics: Developer Forum, User Forum
Apr 26, 2012 at 1:25 PM
Edited Apr 26, 2012 at 1:35 PM

 I want a table from another website. For testing purpose i have made an html file and saved it on my desktop with following code:

    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">   
<body >

     <form  method="POST" action="targetsite">

   <input type="submit" value="submit" id="Button1"/>
   <input type="hidden" name="searchpl" value="7884" />
   <input type="HIDDEN" name="NRequest" value="parameterN"/>

When i click submit button it works fine and redirect me to targetsite. but i dont want to be redirected to targetsite instead i want to get the targetsite second table data. now i know htmlagilitypack can do it, i have tested a site and it works fine but i dont know how to send post data in htmlagilitypack with above information. Can you help? there is an error when i use this code

WebClient myWebClient = new WebClient();
        var doc = new HtmlDocument();

        NameValueCollection myNameValueCollection = new NameValueCollection{
        {"searchpl","BZA 7884"}

        byte[] responseArray = myWebClient.UploadValues("TargetSite", "Post", myNameValueCollection);
        xRow = "/html[1]/body[1]/center[1]/table[1]";
       divScrap.InnerHtml= doc.DocumentNode.SelectSingleNode(xRow).InnerText.Trim();


Error detail: An Error Has Occurred Your session has timed out or expired.