By using WebClient
in C#
, I can get the source of a page. Imagine that this HTML source always contains a form with a given name like this:
<form name="myform" action="page.php">
<input type="text" name="mytext" value="default text">
<textarea name="mytextarea">content</textarea>
<input type="password" name="mypass" value="12345">
<input type="hidden" name="myhiddenfield" value="code">
<input type="checkbox" name="mychb1" value="true" checked>
<input type="checkbox" name="mychb2" value="true">
<input type="radio" name="myradio" value="radio2" checked>
<input type="radio" name="myradio" value="radio1">
<select name="mychoice">
<option value="cherry">cherry</option>
<option value="orange">orange</option>
<option selected="" value="apple">apple</option>
</select>
<input type="submit" value="Submit">
</form>
Now I want to make POST data according to these values like this:
mytext=default text&mytextarea=content&mypass=12345&myhiddenfield=code&mychb=true&myradio=radio2&mychoice=apple
Note that mychb2
is not included because is not checked and also the names might be vary in each page source and there might be more or less than elements in the forms.
How can I do this?