I am trying to use a programming language to search google or another specified search engine. I would like to use windows cmd prompt to do so because the specified programming language has a simple command to access the cmd prompt.
Any ideas on how to search google from cmd prompt?
Simply type this on the command-line or in the run command and it will open your default browser to let Google search for
SEARCHTERM
:Note that you have to replace whitespaces with pluses, e.g.
Alternatively you could also put this command in a batch file:
start www.google.com/
If u are using java then it is damn easy...
Hope this works! Kudos.
I created a Batch file 'g.bat' and added it to my PATH. It looks like this:
Supports up to 5 words (of course you can add more). Now I can search from CMD or start by typing "g query"
Edit: Credit to mrt for the inspiration
I suppose you could use wget from the command line.
Or
-O- -q
to output to stdout. Scraping the results from the html will be a different matter entirely, though.If you do get wget, might as well get grep as well, or just get all of GnuWin32 as it's quite useful. Then you can do stuff like this:
... to get the URL of the first link from a Google search. The sky's the limit. Get creative.
(Output of the example command above:
isaksen.biz/blog/?p=470
)If you want to display the first title plus the first URL, it gets a little more complicated.
Usage:
search.bat up to 9 search terms here
Example:
Maybe this?
Save it as .bat and boom!