Tuesday, 15 June 2010

How can I pass form values like email, name, phone etc from my C# console application to any website? -



How can I pass form values like email, name, phone etc from my C# console application to any website? -

how can pass values email, phone, name etc... website console application. want develop console application open website url , fill form , submit it.

using system; using system.diagnostics; using system.net; namespace samplenamespace { public class sampleclass { public static void main() { string url; string browser=""; string browserpath=""; console.writeline("please come in website url (eg. http://www.google.com): "); url=console.readline(); while(browser.toupper()!="chrome" && browser.toupper()!="mozilla" && browser.toupper()!="ie" && browser.toupper()!="opera") { console.writeline("in browser want open website? (chrome | mozilla | ie | opera) "); browser=console.readline(); if (browser.toupper()!="chrome" && browser.toupper()!="mozilla" && browser.toupper()!="ie" && browser.toupper()!="opera"){ console.writeline("please come in right option!!!"); } if (browser.toupper()=="chrome") { browserpath=@"c:\users\weblink\appdata\local\google\chrome\application\chrome.exe"; } else if(browser.toupper()=="mozilla") { browserpath=@"c:\program files\mozilla firefox\firefox.exe"; } else if(browser.toupper()=="ie") { browserpath=@"c:\program files\internet explorer\iexplore.exe"; } else if(browser.toupper()=="opera") { browserpath=@"c:\program files\opera\opera.exe"; } process.start(browserpath,url); system.console.writeline("please press eenter key exit!"); console.readline(); } } }

if goal post website application don't need worry using browser.

you can connect straight website in question using java library (eg: http://hc.apache.org/httpclient-3.x/apidocs/org/apache/commons/httpclient/httpclient.html)

there plenty of examples of sending http post requests around:

java - sending http parameters via post method easily http://sigterm.sh/2009/10/simple-post-in-java/

you don't need load form in question (usually). can supply post request form's action (destination).

suppose form in question came http://example.com/forms/

you post url http://example.com/forms/contact.html

if you're trying develop spam bot, you're way behind curve ;-)

c# website console

No comments:

Post a Comment