5 ms·
Show HN: Search Google, GitHub, Stack Overflow, other sites from the terminal
- danso 11y agoI didn't install and run the code, but this appears to be a wrapper for performing a search across these sites via browser...i.e. you specify a provider and the query, and the browser pops open with the properly formatted URL, rather than it doing the query, scraping the results and streaming into stdout. Because I was thinking, there's no way it could be this easy to programmatically search Google: https://github.com/zquestz/s/blob/master/providers/google/google.go https://github.com/zquestz/s/blob/master/providers/google/go... func (p *GoogleProvider) BuildURI(q string) string { return fmt.Sprintf("https://www.google.com/search?q=%s", url.QueryEscape(q)) }
- Cederfjard 11y agoYep, the readme says: >Web search from the terminal. Just opens your default browser.
- danso 11y agoYeah, I was thrown off by the repo description -- "Open a web search in your terminal." -- and just dived into the repo before getting to the README.
- zquestz 11y agoCorrect, I am not a fan of listing the results in the terminal itself. I like the flexibility of it loading in a browser so I can click around after the search. It also makes adding additional search providers much much easier.
- woodruffw 11y agoActually, it is that easy to programmatically search Google. Here's the endpoint: https://ajax.googleapis.com/ajax/services/search/web?v=1.0&rsz=small&safe=active&q=cats&max-results=10&v=2&alt=json https://ajax.googleapis.com/ajax/services/search/web?v=1.0&r...
- danso 11y agoIt appears to be officially deprecated as of November 2010, though it is perhaps one of those heavily used APIs (such as static charts API) that Google is in no rush to disable https://developers.google.com/web-search/docs/?hl=en https://developers.google.com/web-search/docs/?hl=en
- woodruffw 11y agoAh, I didn't realize it was deprecated. Just about every IRC bot out there uses it ;)
- TeMPOraL 11y agoExcept mine, because I started looking for it post-2010 and got stuck on Google's new whatever-it-is that has complexity beyond imagination and a seriously buggy dev panel.
- samfisher83 11y agoI think all the new ones you need an api key.
- Kerrick 11y agoA while back I created a command line Google search client that actually functions like you were thinking. http://kerrick.github.io/google/ http://kerrick.github.io/google/
- niutech 11y agoThe results should also appear in the terminal, then it will be a real tool, not just a browser-opener.
- nchelluri 11y agoOk, so that's exactly what I thought this program did (display results in the terminal), so I downloaded it and installed it. When I found that it opened a web search I was quite surprised and came to look at the comment thread. However, should the results appear in the terminal (i.e. do I agree with you)? I am not at all sure that this browser view is a bad thing. The idea of searching from the command line and focus moving to the browser is just not something I was picturing at all, and I kind of like it. But I definitely do agree 100% that I was and am interested in something that runs these webapps from the command line and makes the terminal a first class interface to say, Google, StackOverflow, etc. I think I may try to tinker with such a thing, and when I thought this project had it, I was really curious to see what method of scraping they used and how they turned web data into meaningful result objects of some sort. Thinking about it, I feel like noting two things: 1 - I don't see why a single application, like s, can't support both interfaces. Give it an alias, say, r, and r renders search results at the command line instead of the browser. No reason the list of providers has to be the same for both interfaces. 2 - now we're on web like 2.9999999, right? Googlebot indexes JS/dynamic webpages properly, and webapps use a lot of JS to perform their basic functions, it seems. i believe it's time to start taking command line browsers seriously again. we have a few production ready off-the-shelf JS engines to choose from today and browsing from terminal seems like a simple and why-the-hell-not idea. Terminal/shell interfaces, imo, provide a really great way to move around, focusing on text and with the super quick functional input response that only keyboard navigation can provide. i am positive that if we started aiming for a web development standard supporting JS and HTML5 or whatever well supported but capable standard is out there today and full accessibility from a text-only/terminal web browser (Lynx for 2015's HTTP realities) then we would be helping out people using non-standard input devices (screen readers, etc.). of course im talking out of my ass here, but someone knowledgeable back me up on this point please. i guess it just didn't completely click until i saw this app, someone else who had the same idea as me (you/your post), and the fact that repo this is useful, but not what i was looking for, that i have decided i feel extremely strongly that now is the time for a fully functional javascript capable cross platform browser that does not render graphics at all and runs happily in the terminal. On another note: the project README has very simple and well highlighted Installation instructions, if you happen to have Golang installed, which I do. but not sure how easy that would be if you didn't. A suggestion to the author: post Windows/Mac/Linux binaries on https://github.com/zquestz/s/releases https://github.com/zquestz/s/releases .
- dlokesh 11y agofunction gs() { open http://www.google.com/search?q="$*" ;}
- cpks 11y agoThe license information is broken too. README says All Rights Reserved. License file says MIT.
- zquestz 11y agoThis has been fixed. It is MIT.
- smartmic 11y agoAlternative: surfraw - written by a famous person: https://surfraw.alioth.debian.org/ https://surfraw.alioth.debian.org/
- wittyfool 11y agoSince results are displayed in browser window, There should be a "Search on google" in context menu displayed on right click after text selection in terminal. It will save some clicks like in Google Chrome. There was one similar package available for earlier versions of ubuntu(http://ubuntuguide.net/ubuntu-13-0412-10-terminal-with-search-in-google-support http://ubuntuguide.net/ubuntu-13-0412-10-terminal-with-searc...)
- x1024 11y agoWhy is this written in Go and not Shell? Why isn't this just one file? Here is how such tools should really be done: https://github.com/rupa/z https://github.com/rupa/z
- fiatjaf 11y agoWhat do you mean "written in Shell"? Because you want it to work only in some shells and not others?
- x1024 11y agoAre we still pretending that it's impossible to write portable shell code? Ok, then. Maybe it is in the general case, but this... really isn't "the general case".
- fiatjaf 11y agohahahah, yeah.
- zquestz 11y agoI didn't want the users on Windows to require cygwin to run this. That dependency is huge and would be required if they want shell support in Windows.
- oolongCat 11y agoWell no one is stopping you from writing it in shell.
- x1024 11y agofunction gs() { open http://www.google.com/search?q="$*" ;} https://news.ycombinator.com/item?id=10966210 https://news.ycombinator.com/item?id=10966210 "So difficult, definitely requires installing 100MB of libraries and package managers."
- 11y ago
- bluetomcat 11y agoThis tool might be helpful if you are regularly searching for the same phrases and make aliases to, for example, `s "what is the weather"`. For regular interactive usage this would actually hamper your productivity because you type "s", a space, eventually a starting quote, the phrase without autocompletion, and an eventual ending quote, versus switching to a browser window and focusing over its location bar with two key shortcuts.
- broodbucket 11y agoName conflicts with s [1], which I use a ton of in my terminal every day. [1]: https://github.com/haosdent/s https://github.com/haosdent/s
- d0ugie 11y agoReminiscent of autojump, https://github.com/wting/autojump https://github.com/wting/autojump