need help with a custom web browser

Please support our C# advertiser: $4.95 a Month - ASP.NET Web Hosting – Click Here!
Reply

Join Date: Jan 2009
Posts: 1
Reputation: scylefice is an unknown quantity at this point 
Solved Threads: 0
scylefice scylefice is offline Offline
Newbie Poster

need help with a custom web browser

 
0
  #1
Jan 6th, 2009
Hello, I'm trying to make a custom web browser. I'm using the webBrowser control that does a huge part of the job for me. I wanted to add a search option to it (when you click search the browser sends you to lets say google and shows you the results). What I can't figure out is how to send the string that the user is looking for to google.com and to have it display the results.
Any help would be appreciated, thanks in advance!
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: need help with a custom web browser

 
0
  #2
Jan 6th, 2009
Well if you've worked out how to read a page, posting to a page shouldnt be that much harder. have you tried posting the variable to the search page?
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 306
Reputation: Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough 
Solved Threads: 36
Diamonddrake's Avatar
Diamonddrake Diamonddrake is offline Offline
Posting Whiz

Re: need help with a custom web browser

 
0
  #3
Jan 10th, 2009
you weren't to specific, but i am going to assume you are going for the internet explorer7+ and firefox style search box where the search box is a separate text box, this code would imply that you have a webbrowser control called "webbrowser1" and a textbox for the search called "searchTxt" and this code would be in a click event method for a search button.

  1. string breaker = " ";
  2. char[] delimiter = breaker.ToCharArray();
  3. string[] splitterArray = searchTxt.Text.Trim().Split(delimiter);
  4. string queries = "";
  5.  
  6. foreach (string s in splitterArray)
  7. {
  8. queries += s + "+";
  9. }
  10.  
  11. //remove extra plus at the end of queries
  12. queries.Substring(0, (queries.Length - 1));
  13.  
  14. webbrowser1.Navigate("http://www.google.com/search?q="+queries);

first we create a delimiter to separate the search terms for use on google, this would also work for yahoo, and wikipedia, and many others you just have to check where to put the queries and get the search url from their site this is set up ready to work on google

then we take the string from the search text box and separate it by spaces into an array, after that we loop through the array and add all the search words together into one string adding a + between each one because this is the format that google and yahoo both use.

then we use substring to remove a + that is added at the end that is unnecessary, this could have been avoided, but this is a simple and effective solution, so we will go with that.

finally we take the url of google's search page with its query string ready to accept our values, and we simply add to it our search queries variable and put it in the Navigate function of the webbrowser control.

and we have our search results!

this is just one way, be creating, be inspired, just be anything but satisfied. This will get you started. but if you want to have happy users you will need to give options to choose which search engine they want to use, or even add their own search engines!

Happy Coding!!!
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC