Command the Web - an ELinks tutorial

25 July 2007

Command-line browsing is not always the best approach; e.g. for flickr or a webcomic, it is the wrong approach of course.

However, for most things command line browsing works well. The system requirements are very low indeed. It is fast and secure; web pages have a consistent look and there are no flashing adverts, pop up windows or other web annoyances.

About ELinks

ELinks is the coolest command line web browser, indeed it is the only command line web browser that is both still actively developed and supports modern web pages. So as they say where I come from, "it is a good thing you like potatoes". You can think of ELinks as the Firefox at the command line, only cooler and more fun.

http://commandline.org.uk/images/posts/apps/elinks.png

Available from all good Linux/BSD package managers (the package name is normally just elinks). Gentoo users will want to look at the USE Flags carefully and enable everything that you are familiar with, you probably do want Javascript, otherwise many webpages will not work as you expect.

You might want to install it now; then this tutorial is rather more fun. You might want to put your xterm or PuTTy window in one part of the screen and this webpage in the other.

You can just type elinks to start the program, you can also add a domain name, for example:

elinks commandline.org.uk

Basic usage tutorial

Once in the program you use the 'g' key to bring up the address bar (i.e. the 'Go' box). Now you can type in where you want to go.

http://commandline.org.uk/images/posts/apps/elinks2.png

Navigation is pretty obvious. The 'home' key takes you to the top, 'end' to the bottom. Page Up and Down do what they say, you can also just whack the space bar to scroll down through a page. Hit the right cursor key (or Enter) on a hyperlink to follow it, use the left cursor to go backwards. Use the up and down cursor keys to work through the available hyperlinks.

When you want to use a form field or text box, select it with the up and down cursor keys then press Enter to select it for text-entry.

Use the forward slash '/' to search for a word on the page, then use the 'n' key to show the next occurrence.

In rare cases, the webpage might not fit horizontally into your window, in that case use the square brackets [ ] to scroll the page left and right respectively.

Use q to quit and go back to your terminal.

If you haven't already, then you probably want to get used to these basic commands first. When you are comfortable with the interface, then try to use some of the more advanced features outlined below.

Incidentally, if you know Emacs keybindings, many of the basic Emacs movement and navigation commands work in ELinks also. If you want to use a mouse for cut and paste, you need to hold down shift while you select text.

Basic Commands

g - go to URL (bring up address bar)

Home - go to top of page

End - go to bottom of page

Left - go back

Right - follow hyperlink

Up - previous hyperlink

Down - next hyperlink

/ - search

n - next occurrence

[ - scroll window left

] - scroll window right

q - quit

More Commands

d - download hyperlink

ctrl r - refresh

- view HTML

s - bookmarks

h - history

o - options (i.e. browser preferences)

Tabbed Browsing

c close tab

t Open new blank tab

T Open link as tab

< > Move to left/right tab

Alt < Alt > Move tab lef /right

http://commandline.org.uk/images/posts/apps/elinks3.png

URL Shortcuts

ELinks has a URL shortcut feature, you can type special keywords into the 'Go' box (i.e. the address bar) and it will resolve them into URLs. You can define your own shortcuts to your favourite sites, but there are also a number pre-included.

Depending on how the shortcut has been set up, you either type the keyword shortcut alone or you type the keyword shortcut with extra terms (sometimes both). In this latter case, you can type one or extra terms which will be sent as form data in the get request, the significance of these extra terms will vary according to the context.

That last sentence was a long way of saying that you can type 'g fish' and it will search Google for 'fish'.

I decided to contrentrate on these dynamic shortcuts, so in all of the keyword shortcuts featured below, you can at least do it with the keywords, sometimes the keywords are optional.

Top Three Shortcuts

The podium places go to:

g - search google

wiki - lookup a term in the wikipedia

sd - slashdot - popular technical news site

http://commandline.org.uk/images/posts/apps/elinks4.jpg

Dictionaries

There are three dictionaries, and two thesauri.

cambridge - Cambridge Advanced Learner's Dictionary

d - The Collaborative International Dictionary of English

dict - dictionary.reference.com

mw - Merriam-Webster

mwt - Merriam-Webster Thesaurus

thes - thesaurus.reference.com

Open Source software

All the following shortcuts will help you find free and open source software:

dpkg - debian packages

fm - freshmeat

fsd - fsf directory

savannah - Savannah

sf - Sourceforge

More Search

dmoz - open directory

imdb - film search

g - google search

gn - google news

gr - google groups (aka Usenet)

Geeky links

py - Python Documentation

whatis - server uptime etc

vhtml - w3 validator html

vcss - w3 validator css

emacs - emacs Wiki

More Shortcuts

That is enough to give you an idea of the power of elinks' shortcut feature. Other miscellaneous shortcuts include:

bb - use the babelfish translator

arc - use the Internet archive web archive to look up past versions of pages, very useful when you find that you have followed a dead link.

http://commandline.org.uk/images/posts/apps/elinks5.png

Adding a new shortcut

Let's add a new shortcut.

  • Press the 'o' key to open the options window.
  • Scroll down to Protocols and hit space to expand the category.
  • Scroll down to URI rewriting and hit space to expand the category.
  • Scroll down to Dumb Prefixes and hit space to expand the category.
  • Press the right cursor key and select 'Add', press enter.
  • Type clw
  • Press the Enter key
  • Use your cursor keys again to select 'Edit', press enter.
  • Type or paste into the box the following URL: http://commandline.org.uk/#warrior
  • Select Save, press enter
  • Select Close, press enter

Now from the main ELinks window, you can press the 'g' key, type 'clw' and be back here!

Well that's all for now, in a future post I will look at scripting ELinks. Do let me know how you got on using the comments below. Enjoy the command-line web. Surf's Up!

http://commandline.org.uk/images/posts/apps/elinks6.png

1 Bug says...

I'm fine with w3m. Thanks.

Posted at 7:10 a.m. on July 25, 2007


2 Phill says...

Hmmm, I've always found text-based browsing to be a little tedious - especially if you have a website like mine (i.e., loads of links appearing at the top before you get to the actual content).

Very useful, though, if you want to browse the web over SSH (which you have to do sometimes, i.e. if you're logging into a work PC via SSH and you want to do something via a web-based control panel...)

Posted at 8:10 a.m. on July 25, 2007


3 anonymous says...

I find the way you can navigate in lynx very enjoyable (I'm sure it's the same model for elinks). After getting used to INS and DEL for scrolling (I don't see these keys in your tutorial?) I immediately mapped them in vim. (Because you've got to have something between line-by-line scrolling and page scrolling (on a single key!))

Posted at 9:49 a.m. on July 25, 2007


4 Tami says...

Thank you very much for yet another splendid tutorial which enriched my modest collection of "cheat-sheets"(together with shortcuts for vim, bash and emacs) ;). Being a fan of simple tools I let myself to add one more tip: to import your bookmarks from fi. Firefox to Elinks either convert the format from .html to .xbel using CLI(xbel_parse ?) or go to http://www.linkagogo.com/ where you can convert your bookmarks online and then move the bookmarks.xbel file into your .elinks directory. I'm looking forward to your next tutorials and once again many thanks from grateful reader,

tami

Posted at 10:49 a.m. on July 25, 2007


5 d says...

You missed the one key that actually makes elinks usable: . Yes, the period key. It turns on link numbers next to each link, so it makes it really easy to jump to links. Simply type the number and then enter and you jump to that link

Posted at 5:18 p.m. on July 25, 2007


6 Brian Wisti says...

Good stuff! I've been using elinks for a little while, but had never really delved into it. Never even bothered to learn the shortcuts. Found you from a random google search for elinks, and now I'll be using those shortcuts all the time. Thanks for taking the time to post.

Posted at 10:28 a.m. on January 28, 2008


7 Mike says...

Can you tell me where you got the background image with the girl please.

Posted at 8:56 a.m. on May 13, 2008


8 Mike says...

Please tell me where you got the background image with the girl please.

Posted at 9:50 a.m. on July 1, 2008


9 Joe says...

Now - thanks to this article - I just type "links markets" and I have instant world wide market listings - good thing I work on the first floor ;-)

Posted at 10:22 a.m. on October 29, 2008


10 Bassam essa says...

thanx man i need to know how i can download html source page from elinks ? i try $ elinks - view HTML "http://www.google.com/" > resulthtml.txt but its dont work :( thanx again

Posted at 2:55 p.m. on December 25, 2008


11 Bassam essa says...

i try this line command elinks -source "http://www.e51g.com/" > resulthtml.txt

its work done :) thx

Posted at 3:09 p.m. on December 25, 2008


What do you have to say?

Show Editing Help

About

Hello, my name is Zeth, I'll be your host here.

Command Line Warriors is about taking control of your own technology, it looks at our experiences of computing; especially using GNU/Linux, the Python programming language, the command-line and issues such as techno-ethics, best practices and whatever is cool now. If you take control of your technology then you are a Warrior too!

This site is your site too which means that you can contribute and get involved. You can leave comments using the facility provided. For me, the comments and discussions are by far the best part of the site. So please do have your say!

Latest Discussions

Zeth

November 29, 2009
Hi Jordan, yes that URL is gone now. I have a new contact form on this site.
Python CGI contact forms

Jordan

November 29, 2009
Zeth attention! Your form, http://zeth.me.uk/contact/, is not working The explorer says connecting ..but nothing happens Sorry for my poor English: I am Spanish Regards
Python CGI contact forms

Jordan

November 26, 2009
Sorry: tell me , not tellme (I'm spaniard) And http://zeth.me.uk/contact/ don't work
You got the touch, you got the power

David Jones

November 25, 2009
Your mad skillz are too l33t! for me. I specifically switched to Google Reader so that I could show people what blogs I read. But I couldn't work out how ...
How to find the fashionable blogs quickly

Brian R. Hickey

November 20, 2009
Symantec picked it up too.
How to bring down Internet Explorer with six words

Zeth

November 17, 2009
Thanks djm, I am the moose here. Christian, assuming one actually does Internationalise the countries, it should still work I guess, as the gettext stuff will happen before the list ...
Countries in Django

Phillip Temple

November 17, 2009
Good start, but: a) wouldn't I want None back rather than 'ZZ'? b) why not add a 'shortcut' boolean, then prepend flagged fields (plus usual '-----' separator) to the actual ...
Countries in Django

djm

November 17, 2009
Am I being a moose or did you mean: from whatever.countries import CountryField instead of from whatever.countries import CharField ? Good post though, cheers.
Countries in Django

Christian Joergensen

November 17, 2009
Wouldn't the ordering get messed up after i18n?
Countries in Django

Steve - Electronic Cigarettes Fan

November 17, 2009
Very well done. Is your blog just you writing? Nicely done, Steven.
Blogger vs Wordpress

vetetix

November 15, 2009
Sorry to bother you nearly two years after you wrote this blog article, but I can't manage to find how to modify an existing field. I am trying to change ...
Three Useful Python Bindings - ClamAV, Apt and Evolution

Manju

November 4, 2009
I am transferring some files using psftp to other device's FAT partition. But the filestamp of the file being transferred is modified to that of FAT device, after the transfer. ...
PuTTY Series: Using PSFTP

iki

November 2, 2009
or simpler: socket.gethostbyname_ex(socket.gethostname())[2]
How to find out your IP address in Python

iki

November 2, 2009
local_ip = set([ i[4][0] for i in socket.getaddrinfo(socket.gethostname(), None) if i[0] == 2 ])
How to find out your IP address in Python

Fred

November 2, 2009
testing rst ------------- - point 1
An Introduction to ReStructuredText

Ano

October 27, 2009
"You simply found the license of the StumbleUpon Toolbar for Internet Explorer." That's possible. I've got some more interesting information to add. Firstly, go to this page: https://addons.mozilla.org/en-US/firefox/addon/138 - this ...
Are your Firefox extensions proprietary software?

Ken

October 21, 2009
Stumbled in here at lunch. This is the best find of the week. Thanks.
Three classic command line tips

Jim

October 19, 2009
Thanks for the rtsp:// post - that's something that has been bugging me for a while!
Three classic command line tips

Zeth

October 18, 2009
Thanks for the comments guys. Great to see the all the gang are still here!
Three classic command line tips

Bubba

October 18, 2009
Is there any way psftp can return the true transfer rates oberved during the actual transfer?
PuTTY Series: Using PSFTP