Quantcast
Channel: htmlagilitypack Forum Rss Feed
Viewing all articles
Browse latest Browse all 655

New Post: how to get table from another website with method=post

$
0
0

 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:

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

     <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"/>
        </form>
    </center>
</body>
</html>

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"}
        ,{"NRequest","ChannelType=ct/Browser|RequestType=rt/Business|SubSystemType=st/Payments|AgencyType=at/PVO|ServiceName=PVO_VIO_BY_PL|PageID=PVO_Search|PVO_V_NUMBER=|P_ID=BZA7884|PVO_SEARCH_T=false|PVO_CO=TRUE|PVO_P_TYPE=PAS|PVO_S_NAME=NY"}
                };

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

 

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


Viewing all articles
Browse latest Browse all 655

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>