Using WebRequest to post data after page found.

Posted on 2005-04-25
Medium Priority
Last Modified: 2011-09-20

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) {
      sLine = objReader.ReadLine();
      if (sLine!=null)


I get the following back:

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>

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.



Question by:sads
  • 2
LVL 37

Accepted Solution

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

Expert Comment

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


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