Manipulate OTHER websires in C#?

  • Thread starter Thread starter Lazamataz
  • Start date Start date
L

Lazamataz

This might seem like a beginner question. Thats okay, I'm a beginner.
:o)

I have no problem connecting to and doing WebRequest and WebResponse
and getting a stream I can convert to RawHTML.

What I REALLY Need, tho, is -- even if I have to look inside that HTML
-- to manipulate an HTML Option to a particular value, and even more
importantly, to click a particular SUBMIT button -- programmatically.

Any ideas?
 
(e-mail address removed) (Lazamataz) wrote in @posting.google.com:
This might seem like a beginner question. Thats okay, I'm a beginner.
:o)

I have no problem connecting to and doing WebRequest and WebResponse
and getting a stream I can convert to RawHTML.

What I REALLY Need, tho, is -- even if I have to look inside that HTML
-- to manipulate an HTML Option to a particular value, and even more
importantly, to click a particular SUBMIT button -- programmatically.

Any ideas?

You will have to analyze the form and then create a new WebRequest with
according QueryString or Postdata to send to the Webpage that is the Target
of the Form.

greets
peter

--
------ooo---OOO---ooo------

Peter Koen - www.kema.at
MCAD CAI/RS CASE/RS IAT

------ooo---OOO---ooo------
 
You will have to analyze the form and then create a new
WebRequest with according QueryString or Postdata to
send to the Webpage that is the Target of the Form.
greets, peter

Well, yes. Actually I did think of doing that -- if, of course, I am not
misreading your message.

But the problem is, when I get a response page on my browser, the
important ?var1=val2&?var3=val4 info is stripped off by the server on
the other side, and I'm not sure the order that these var's and val's
might be in. The order seems to be significant, it barfs every time so
far.

If there is, in this form, several OPTIONS in a row, do ALL of them get
appended to the URL? In the order they appear in the HTML doc? Are ALL
hidden SUBMITS also appended, also in order?

I should do a manual test once or twice to see if I can get it to do
things right "by hand". If so, all I need to do is set up a nice URL
string to submit WebRequest-wise.

To be exact, I was really hoping for a cute little C# trick. You know,
something like
System.WaveHandsMagically.SomebodyElsesWebPage.Option1.Select = 1 and
System.WaveHandsMagically.SomebodyElsesWebPage.SubmitButton1.Click....

:o)
 
This is probably an ugly way of doing it and I haven't tried it in C# so
far.

Why don't just create an IE object. If you have the names of the boxes and
buttons you can just fill them in and simulate a click. That way you have no
problems with postdata or querystrings since everything will be formed by IE
the way it has to be before it is send. But your memory footprint will
probably be larger since you will have an IE instance open.

Yves

' *********** VB-classic example ***********
Set IE = CreateObject("Internetexplorer.Application")
IE.Visible = True ' If set to true you can see everything getting filled
in
IE.Navigate ("http://www.somewhere.com")
' Wait till the page is fully loaded
Do Until IE.ReadyState = "4" And Not IE.Busy
DoEvents
Loop

' login
IE.Document.All("username").Value = "myname"
IE.Document.All("pword").Value = "mypass"
IE.Document.Forms(0).Submit ' enter
' Wait till the page is fully loaded
Do Until IE.ReadyState = "4" And Not IE.Busy
DoEvents
Loop

' ************* end code *************
 
This is probably an ugly way of doing it and I haven't
tried it in C# so far.

Why don't just create an IE object. If you have the
names of the boxes and
buttons you can just fill them in and simulate a click.
That way you have no
problems with postdata or querystrings since everything
will be formed by IE
the way it has to be before it is send. But your memory
footprint will
probably be larger since you will have an IE instance
open.

Well, I've done something similar in Visual Fox 8.0, so I know how to do it,
but... I was hoping to avoid it.

I did have some success this morning just creating a URL with all the
querystrings set up right. I guess this is the way to go.

Sheesh. I thought C# was supposed to be *cool*. My faith is shaken. ;^)

Thanks for the answer, Yves....
 
Back
Top