Using WebRequest to post data after page found.

Hi

I'm trying to access (screen scrape) a secure web page (have that working) that contains some radio button options.  Problem is how do I post and trigger the radio button after I pull the HTML from the secure site?

Here's the code and the output so far:


String MyURI = "https://mySite.com/cgi-bin/orders/textedit.pl";
WebRequest WReq = WebRequest.Create(MyURI);

NetworkCredential cred = new NetworkCredential("id", "pass");
WReq.Credentials = cred;

Stream objStream;
objStream = WReq.GetResponse().GetResponseStream();
StreamReader objReader = new StreamReader(objStream);

string sLine = "";
int i = 0;
while (sLine!=null) {
      i++;
      sLine = objReader.ReadLine();
      if (sLine!=null)
            Console.WriteLine("{0}:{1}",i,sLine);
}

objReader.Close();
objStream.Close();
WReq.GetResponse().Close();



I get the following back:

<html><head></head><body>
2:<form action=/cgi-bin/orders/textedit.pl METHOD=POST>
3:<input type=radio name=file value="check-form-log.txt">check-form-log.txt<br>
4:<input type=radio name=file value="booking-form-log.txt">booking-form-log.txt<br>
5:<input type=radio name=file value="contactus-form-log.txt">contactus-form-log.txt<br>
6:<input type=radio name=file value="contest-form-log.csv">contest-form-log.csv<br>
7:<input type=radio name=file value="contest-form-log.txt">contest-form-log.txt<br>
8:<input type=radio name=file value="feedback-form-log.txt">feedback-form-log.txt<br>
9:<input type=radio name=file value="submitlink-log.txt">submitlink-log.txt<br>
10:<input type=radio name=file value=".htaccess">.htaccess<br>
11:<input type=submit></form>
12:</body></html>



So at this point what do I post/submit and how do I set up WebRequest to do it?


Any pointers would really be appreciated.


Thanks

Chris

            
sadsAsked:
Who is Participating?
 
gregoryyoungCommented:
http://odetocode.com/Articles/162.aspx gives an example with webclient.
0
 
gregoryyoungCommented:
for radio buttons its ... name=value in post data.

Greg
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.