PC Review


Reply
Thread Tools Rate Thread

Click a button on a web page through c#

 
 
Steven Nagy
Guest
Posts: n/a
 
      3rd Sep 2006
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

 
Reply With Quote
 
 
 
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      3rd Sep 2006

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
-------------------------------------------------------


"Steven Nagy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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
>



 
Reply With Quote
 
Steven Nagy
Guest
Posts: n/a
 
      4th Sep 2006
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?

Alvin Bruney [MVP] wrote:
> yup, you can just post and pass in the required variables. You can get this
> variables from the page source or query string.


 
Reply With Quote
 
Alvin Bruney [MVP]
Guest
Posts: n/a
 
      5th Sep 2006
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
-------------------------------------------------------


"Steven Nagy" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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?
>
> Alvin Bruney [MVP] wrote:
>> yup, you can just post and pass in the required variables. You can get
>> this
>> variables from the page source or query string.

>



 
Reply With Quote
 
Steven Nagy
Guest
Posts: n/a
 
      5th Sep 2006
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.

 
Reply With Quote
 
alex_f_il@hotmail.com
Guest
Posts: n/a
 
      5th Sep 2006
You can do it very easily with SWExplorerAutomation (SWEA)
(http://webunittesting.com)


Steven Nagy wrote:
> 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


 
Reply With Quote
 
Steven Nagy
Guest
Posts: n/a
 
      5th Sep 2006
Nice concept. I'll definately have a play sometime this week.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Click the button on the page Alexander Vasilevsky Microsoft ASP .NET 1 11th Jun 2008 05:48 PM
How to simulate button click on a page? Hooyoo Microsoft ASP .NET 1 5th Sep 2007 05:58 PM
Programatically click a web page button =?Utf-8?B?UGV0ZQ==?= Microsoft C# .NET 3 16th Dec 2005 03:49 PM
Page load of the parent page called twice when a modal dialog is opened from a button click of the user control on the parent page Samy Microsoft ASP .NET 2 15th Aug 2005 04:30 PM
Page.SmartNavigation = True (Button click and Page refresh issue) Lenny Shprekher Microsoft ASP .NET 0 23rd Feb 2005 06:39 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:14 PM.