activate search engine from code
Hi!
I jus wanna noe if there can be such a way for a c++ or c# program to activate
a search engine(google) on the web to return a list of top 10 documents found for the search.
thx!
Edwinz
Well I know there is definitly a way in C++, so there has to be a way in C#. Here is the theory of it:
1. Get search query from user in program.
2. Program generates an url to be searched with:
EX: http://www.google.com/search?hl=en&q=Test&btnG=Google+Search The red will never change, but you can change around the orange. Of course you could use a lot of other search engines as well [smile]
3. Using something like WinSock (standard networking stuff on Windows), you download the page and store it in memory. More than likely, you would use the Standard C++ library to ease with manipulation.
4. With that all you have to do is parse through the file.
EX: If you look at the source results, all you would have to do is obtain the data between the tags to get all the data, to which through further processing, you can generate a list of what you need. I can't post the tags because GameDev will try to use them, but if you look at the source you should see a division of it.
1. Get search query from user in program.
2. Program generates an url to be searched with:
EX: http://www.google.com/search?hl=en&q=Test&btnG=Google+Search The red will never change, but you can change around the orange. Of course you could use a lot of other search engines as well [smile]
3. Using something like WinSock (standard networking stuff on Windows), you download the page and store it in memory. More than likely, you would use the Standard C++ library to ease with manipulation.
4. With that all you have to do is parse through the file.
EX: If you look at the source results, all you would have to do is obtain the data between the tags to get all the data, to which through further processing, you can generate a list of what you need. I can't post the tags because GameDev will try to use them, but if you look at the source you should see a division of it.
Have a look into the Google WebAPI, it uses SOAP which will be easier than parsing the HTML in the page
i think that google offers a (limited) free webservice for you to call from your c# application to obtain search results. might be interesting.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement