Click a button on a web page through c#

S

Steven Nagy

Heyas

Writing an app that will manage my local internet connection, including
rebooting the router. The web scraping part is fine (using webrequest)
to get the current router status.
There's a specific page with a button on it for "Reboot" that I would
like my application to be able to click. According to a quick 'view
source' of that page, the button calls a JS function which essentially
calls form.submit anyway. The form method=post.

Essentially I am just not sure where to start with this. Should I be
attempting to post directly to the form action page and upload the
required post data? Or is there an easy way to just click the button?

C# in .NET 3.0 July CTP.

Cheers,
Steven
 
A

Alvin Bruney [MVP]

yup, you can just post and pass in the required variables. You can get this
variables from the page source or query string.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
 
S

Steven Nagy

Even if its a POST, not a GET?
What do you do if the target page is checking the referring page/IP
and won't work if its not from its own site?
 
A

Alvin Bruney [MVP]

There's no way to circumvent the IP checking etc. No way I know of at least.
This is always the sticking point with screen scraping and back door
approaches.

--
________________________
Warm regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
Professional VSTO.NET - Wrox/Wiley
The O.W.C. Black Book with .NET
www.lulu.com/owc, Amazon
Blog: http://www.msmvps.com/blogs/alvin
 
S

Steven Nagy

Ok but in IE, a user can click a button and it accepts it.
There must be someway to simulate this in code. Even if it means using
Macro Express!
I'd prefer not to do it that way though.
What about the new browser control in .NET2.0 ? Can I use that for
"automated surfing"?
In otherwords, have the software take the place of a user. That way the
referring page is still the correct page, and thus passes the security
check.

Anyway, its not a huge deal for me currently because the router wasn't
checking the referrer address. So it is currently working. I was also
surprised how easy the user credential stuff was.

Thanks for helps.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top