Surfraw stands for 'Shell Users' Revolutionary Front Against the WWW'. It's a command-line shell program for interfacing with a big number of web-based search engines. With Surfraw you can search google and wikipedia a.o. from the command line. The results will be displayed with a browser of your choice. I suggest a text browser like links2, to keep it text based. Read more to find out how to install and use it.
1. Install Links2
First we install links2 which is my favorite text browser:
sudo apt-get install links2
quick controls, type:
links2 google.com
OK it works
now type 'q' to quit
navigate with arrows, select with space and enter
esc for more options
2. Install Surfraw
sudo apt-get install surfraw
3. Configure Surfraw
sudo nano /etc/surfraw.conf
look for the line that says
def SURFRAW_text_browser sensible-browser
and change it to
def SURFRAW_text_browser links2
save and exit:
ctrl+x, y, enter
4. Search
now you're ready to go:
Start the command with 'sr', for surfraw, followed by the engine/site you want to search, and in third place your search terms. Like this
sr google sudosys
it will give you:

sr google -l sudosys
the '-l' option is for when you feel lucky
sr wikipedia surfraw
this is the complete list of included engines:
W Activate Surfraw defined web-browser
alioth Search Alioth (alioth.debian.org)
altavista Search the web using Altavista (www.altavista.com)
amazon Search the amazon.com bookstore
archpkg Search Arch Linux packages (www.archlinux.org)
ask Question the web using Ask Jeeves (www.ask.com)
austlii Search Australian Law docs (www.austlii.edu.au)
bbcnews Search BBC News (news.bbc.co.uk)
cddb Search for cd track listings in CDDB (www.gracenote.com)
cia Search CIA documents at www.cia.gov
cite Search computer science papers (www.researchindex.com)
cnn Search on CNN (cnn.com)
codesearch Search source code using Google Code Search (www.google.com/codesearch)
ctan Search the Comprehensive TeX Archive Network (ctan.org)
currency Convert currencies with the Universal Currency Converter (www.xe.net/ucc)
cve Search for CAN assignments in CVE
debbugs Search the debian BTS (bugs.debian.org)
debcontents Search contents of debian/ubuntu packages (packages.debian.org/packages.ubuntu.com)
deblists Search debian mailing lists (lists.debian.org/search.html)
deblogs Show changelogs for a package in Debian main (changelogs.debian.net)
debpackages Search debian/ubuntu packages (packages.debian.org/packages.ubuntu.com)
debpts Search the Debian Package Tracking System (packages.qa.debian.org)
debsec Search the Debian Security Tracker for CVE ids or package names
debwiki Search the Debian Wikis (wiki.debian.org & women.debian.org/wiki)
deja Search usenet using Google Groups (groups.google.com)
discogs Search the Discogs database of music information (www.discogs.com)
dmoz Search the Open Directory Project web directory (dmoz.org)
ebay Search the Ebay auction site
etym Look up word origins at www.etymonline.com
excite Search on Excite (www.excite.com)
fast Search the web using FAST Search (www.alltheweb.com)
filesearching Search files on filesearching (www.filesearching.com)
foldoc The Free On-Line Dictionary Of Computing (foldoc.org)
freebsd Search FreeBSD related information (www.freebsd.org)
freedb Search for cd track listings in FreeDB (www.freedb.org)
freshmeat Search Freshmeat (www.freshmeat.net)
fsfdir Search the FSF/UNESCO Free Software Directory (directory.fsf.org)
genpkg Search Gentoo packages (packages.gentoo.org)
google Search the web using Google (www.google.com)
gutenberg Search for books on Project Gutenberg (gutenberg.org)
happypenguin Search the Linux Game Tome (www.happypenguin.org)
imdb Search the Internet Movie Database (www.imdb.com)
ixquick Search the web using ixquick (www.ixquick.com)
lastfm Search last.fm
leodict Search Leo's German <-> English dictionary (dict.leo.org)
lsm Search the Linux Software Map
musicbrainz Search MusicBrainz (musicbrainz.org)
netbsd Search NetBSD related information (www.netbsd.org)
openbsd Search OpenBSD related information (www.openbsd.org)
opensearch Search an OpenSearch-enabled website
pgpkeys Search the PGP key database
port Look up a TCP/UDP port number
pubmed Search medical/molbio databases (www.ncbi.nlm.nih.gov)
rae Busca en el diccionario de la Real Academia de la Lengua Española (Spanish Dictionary)
rfc Search RFCs (internet standards documents)
rhyme Search for rhymes et al using Lycos Rhyme (rhyme.lycos.com)
scaleplus Search Australian Law using ScalePlus (scaleplus.law.gov.au)
scholar Search Google Scholar (scholar.google.com)
scpan Search the Comprehensive Perl Archive Network (search.cpan.org)
slashdot Search stories on Slashdot (www.slashdot.org)
slinuxdoc Search entries in LDP (www.linuxdoc.org)
sourceforge Search SourceForge (www.sourceforge.net)
stockquote Get a single stock quote (multiple providers)
sundocs Search docs on Sun.com (docs.sun.com)
sunonesearch Search Sun One Search (onesearch.sun.com)
thesaurus Look up word in Merriam-Webster's Thesaurus (www.m-w.com)
translate Translate human languages (various providers)
w3css Validate a CSS URL with the w3c CSS validator (jigsaw.w3.org/css-validator)
w3html Validate a web page URL with the w3c validator (validator.w3.org)
w3link Check web page links with the w3c linkchecker (validator.w3.org/checklink)
w3rdf Validate a RDF URL with the w3c RDF validator (validator.w3.org)
wayback Search The Internet Archive's Wayback Machine for a URL (archive.org)
webster Look up word in Merriam-Webster's Dictionary (www.m-w.com)
wetandwild Real time weather information (many sources)
wikipedia Search the free encyclopedia wikipedia
woffle Search the web using Woffle (localhost:8080)
xxx Superior XXX, hot and ready to press (arXiv.org)
yahoo Search Yahoo categories (www.yahoo.com)
yubnub Use the social command-line for the web (yubnub.org)
More information about surfraw:
http://surfraw.alioth.debian.org/
http://en.wikipedia.org/wiki/Surfraw
ps. type this in a browser:
http://goosh.org
It's the other way around, a google shell
Comments
interesting tool this. But being a linux-newb i'm just kinda struggling with the following:
I'd like to save the output of the search in a file, how can i do this?
i've tried:
sr freedb testartist >file
but then it hangs(it starts the browser, but puts every output in my file). I just want it to close after it is finished loading the page.
'>' will not work
top of mind; you can save the page in .html or .php
sr freedb annihilatorthis opens links2, hit escape, arrow-down, 'save as' or 'save formatted document'
But you can also achieve it the following way:
sudo nano /etc/surfraw.confchange 'none' from
# text browser arguments, or "none"def SURFRAW_text_browser_args none
to
# text browser arguments, or "none"def SURFRAW_text_browser_args -dump
save it and quit. Now you can do:
sr freedb annihilator > annihilatorsr will construct the url and feed it to links2. Links2 will dump the page into the terminal. This will then be outputted into a file called annihilator in your homedir with the freedb query results for annihilator.
Among other options you can also change the default number of results to return in /etc/surfraw.conf . Just play with it
Hope it helps
Post new comment