Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C
can anyone tell me an easy method of embedding a search engine like Google in C or C++ code
Posted 6-Apr-13 21:48pm
Comments
Richard MacCutchan at 7-Apr-13 3:07am
   
You need to use some form of HTTP handler; see https://www.google.co.uk/search?q=html+c%2B%2B.
pasztorpisti at 7-Apr-13 3:38am
   
Your question is not clear, please make it more precise. Do you want to issue a search request and then get back data that can be interpreted by your program or just put an html view (browser) on your window - because these are not the same. The second can be done easily, not sure about the first one. The first can also be an easy task if the google api supports returning results in xml or json or whatever format (I'm pretty sure they support something like this.)
I don't have experience in this but if noone gives you a good answer then try this:
1. Search for a google search client for c++, if you are lucky someone has already written one for you. If not then go on to the 2. point.
2. Write your own c++ client: you will need an http client library that can be used to download the results for a query by url. For example you request GET "http://www.google.com" and the http client returns an html page as text for you (depending on the url the returned data can be anything - even binary data and not only text or html). You have to search for the google search api and find out whether they have a query parameter that requests the search results in xml, json or whatever format instead of an html page. On a parameter I mean writing for example "http://xyz.com?param=value¶m2=value2&xml=1" instead of just "http://xyz.com". If the google api has such a parameter then you are lucky because then your request will return data in a processable form instead of a html page so you can process it and use for anything you want in your program.
As a HTTP client I recommend using the cURL library that is a mature file transfer library that knows a lot of protocols for file transfer. One of these protocols is HTTP, you can disable all other protocols when you compile the library. (You can leave the "file" protocol turned on for debugging, in this case curl will accept "file://xyzdsf" links too.)

1 solution

Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

If you are looking for a indexing/search engine in c++ then look at : http://clucene.sourceforge.net/[^]
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 Kornfeld Eliyahu Peter 169
1 Zoltán Zörgő 139
2 George Jonsson 135
3 PIEBALDconsult 130
4 OriginalGriff 120
0 OriginalGriff 6,165
1 DamithSL 4,658
2 Maciej Los 4,107
3 Kornfeld Eliyahu Peter 3,649
4 Sergey Alexandrovich Kryukov 3,342


Advertise | Privacy | Mobile
Web02 | 2.8.141220.1 | Last Updated 7 Apr 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100