dcsimg

Old School Browsing with w3m

Not to sound like a Luddite, but sometimes the old ways are best. When it comes to Web browsers, that's not very often, but knowing your way around a text-mode browser like w3m does come in handy from time to time. You probably won't want to switch, but after taking a look at what you can do with w3m, you might want to add it to your toolbox.

Generally, I focus on the cutting edge goodies for the Web, but this week I spent some time with w3m after a long hiatus and thought it might be fun to take a step back and look at the old school Web. I needed to convert a page of HTML to text on the fly, and one of the best tools I’ve found for that is w3m. It’s also a pretty good, if extremely basic, Web browser if all you need to do is read pages on the Web.

Why muck with a text-mode browser? Certainly not because it’s full-featured. Firefox, Chrome, Konqueror, or Opera, any other modern browser will get you more bang for the buck than w3m — though w3m’s rendering speed is pretty impressive. But w3m has a few features that you won’t find in other browsers that make it worth having around.

Checking Site Design

Your site may look picture-perfect in your favorite browser, but what about all the other browsers that you haven’t had time to test? Does it degrade nicely for people on less functional mobile browsers? While the percentage of visitors who hit your site with less-functional browsers may be small, it’s still important to make sure that the site is usable.

Throughout the life of a Web site, it’s a good idea to occasionally fire up a text-mode browser like w3m and see what the experience is like when trying to read and navigate the site in a browser that’s not equipped for fancy CSS layouts or JavaScript functions.

Browser of Last Resort

It has happened, albeit rarely, that I needed a way to get online when it wasn’t possible to get to one of the GUI browsers. Either because X was broken, or when working at a server and needing to get to a download without X installed at all. You’ll find w3m comes in very handy indeed when having to browse to a site and grab a file or files from the console.

It doesn’t happen often, but I find about once or twice a year that I need to roll out w3m in a situation where Firefox or other GUI browsers just aren’t available.

Converting HTML to Text

While using w3m for troubleshooting doesn’t come up too often, it’s not uncommon that I need to convert something in HTML to plain text — and I’ve found that w3m is a really handy tool to do so. Even on some complex pages, w3m has been good at converting HTML to usable text.

It’s very easy to do, too. You can try it by running w3m -dump -T text/html filename.html > filename.txt. If you’re converting an online document, simply replace the filename with the URL.

Scripting

Where w3m really shines is scripting. Which is to say, if you need a browser that can easily be used from a script, w3m is far superior to Firefox or any other GUI mode browser.

For instance, if you wanted to have a quick and dirty way to monitor a Web site, you could knock up a short script that would call w3m, check the content of the page, and then either exit quietly if all is well, or send a message to the person on-call to make sure that everything is up and running smoothly.

Using w3m

Getting w3m shouldn’t be a problem. You should find w3m as part of the default installs of many Linux distros, and it should certainly be packaged up for all popular major distros these days.

If started without an argument, w3m will just display its help file, so you’ll want to tell w3m what site or file to start with if you’re browsing the Web:

w3m http://www.linux-mag.com/

Once you’re in w3m, you’ll need to know a few basic commands to navigate the Web. w3m uses standard Vim movement keys to move around a page, so l will move the cursor to the right, k will move up, j will move down, and h moves to the left.

To scroll more quickly, hit the Space bar, and to scroll backwards quickly through a page, hit b. To go back through your browsing history use the left arrow key or B.

The Tab key will put the cursor on the next hyperlink on the page (if there is one), and Shift-Tab will move backwards to the next hyperlink.

To follow a link, just hit Enter when you’re on the link. If you want to type in a URL, type g and w3m will prompt you for the URL.

If you want to get to w3m’s help, just hit H or ?, which should be pretty easy to remember.

Found a page you want to bookmark? Type a to add it to your bookmarks, and v to view bookmarks.

Finally, to exit w3m hit q and you’ll be prompted to answer whether you’re sure or not you want to exit. If you want to skip that, hit Q to skip the prompt.

I wouldn’t want to spend all my time browsing the Web using w3m, but it does prove useful in a pinch.

Comments on "Old School Browsing with w3m"

dragonwisard

What makes w3m better than other TUI browsers like lynx?

Reply
littlemonkeymojo

… or links?
… or elinks?

Reply
wweng_linux

Why use lynx, when you have links. :)

Reply
grdetil

The author of w3m provides a bit of a comparison to lynx in the introduction of the history of w3m here… http://w3m.sourceforge.net/STORY

Reply
driordan

I\’ve used w3m, lynx, and elinks, and prefer w3m to those others. It seems to do a better job of rendering the pages I\’ve visited and the interface (such as it is) was more intuitive. Then again, I think it was also my first, so that may have biased me towards it.

Reply
dougroyal

Looks like you have your text browsers mixed up

g goes to the top of the document like Vim, it doesn\’t open a url prompt like links

U opens a url prompt

v switches your view (from source to rendered), it doesn\’t let you look at your bookmarks

ESC-a adds a bookmark

ESC-b lets you see your bookmarks

As far as which is better. Well, they\’re all good at different things, so the \”better\” browser depends on what you\’re doing.

Reply
lumix

I was always using the latest browsers when I started browsing the web. I am very much happy that I bumped into this blog. I have never known about text mode browsers all this while. I was very curious about how different a text-mode editor is, so I downloaded and installed the W3M. It is absolutely a different league all together. I totally agree with Joe as I really felt W3M very interesting for the moment. I am very impressed with faster HTML to text conversion through this. Regards
Jane
pst repair

Reply

Major thankies for the post.Thanks Again. Want more.

Reply

Thanks for sharing, this is a fantastic article.Much thanks again. Much obliged.

Reply

I precisely wanted to say thanks all over again. I’m not certain what I could possibly have done in the absence of the actual points provided by you concerning that area. It was a real challenging crisis in my position, however , looking at your specialised technique you managed that made me to weep over delight. I’m just grateful for this help and as well , hope that you recognize what an amazing job you are always getting into teaching the others by way of your blog post. I know that you haven’t got to know all of us.

Reply

It as difficult to find knowledgeable people in this particular subject, however, you seem like you know what you are talking about! Thanks

Reply

miBS5A I truly appreciate this article.Thanks Again. Awesome.

Reply

Every as soon as inside a although we select blogs that we study. Listed beneath are the most current websites that we select.

Reply

Just beneath, are numerous entirely not related web-sites to ours, even so, they may be surely worth going over.

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>