?
Solved

Using WebRequest to post data after page found.

Posted on 2005-04-25
2
Medium Priority
?
374 Views
Last Modified: 2011-09-20
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

            
0
Comment
Question by:sads
  • 2
2 Comments
 
LVL 37

Accepted Solution

by:
gregoryyoung earned 1500 total points
ID: 13863902
http://odetocode.com/Articles/162.aspx gives an example with webclient.
0
 
LVL 37

Expert Comment

by:gregoryyoung
ID: 13863904
for radio buttons its ... name=value in post data.

Greg
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Although it is an old technology, serial ports are still being used by many hardware manufacturers. If you develop applications in C#, Microsoft .NET framework has SerialPort class to communicate with the serial ports.  I needed to…
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Integration Management Part 2
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an anti-spam), the admin…

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question