Link to home
Start Free TrialLog in
Avatar of sads
sads

asked on

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

            
ASKER CERTIFIED SOLUTION
Avatar of gregoryyoung
gregoryyoung
Flag of Canada image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
for radio buttons its ... name=value in post data.

Greg