Cover V13, i12

Article

dec2004.tar

Eight Great Reasons to Love Lynx

Dave Taylor

Take a deep breath, and let's go back in time a few years to Windows 95. Think about people saying "Leenucks? What's that?" and just maybe imagine being in a public place without 10% of the people chatting away on cell phones. Remember an upstart company called Netscape and a browser formerly known as NCSA Mosaic. And let's go back just a little bit further...

When the World Wide Web first appeared on the scene, it was all about content -- not about flashy graphics, animated applets, and wireless browsing hotspots. The first Web browser, in fact, was a text-based browser that only worked in terminal windows.

Browser technology evolved, "document object models" became the vogue, and the Netscape browser was crushed by Microsoft, acquired by America Online, and then resurrected as an open source project that worked across all the major computing platforms.

Meanwhile, a small group at the Distributed Computing Group of the University of Kansas was creating and growing a powerful text-only Web browser called Lynx. In fact, two of the original Lynx developers, Lou Montulli and Garrett Blythe, joined Netscape in 1994. The Lynx program continues to grow and evolve to meet the ever-changing Web and HTML standards, now maintained by a consortium of Internet programmers.

If you've been living in the world of graphical Web browsers, you might just be surprised at how useful a text-only, command-line-based Web browser can be for your daily Internet interactions.

Getting your Own Copy of Lynx

Odds are good that you have Lynx on your computer already (try typing "which lynx" or "locate lynx" to find out), but if you aren't lucky or you find that you have a really old version (the current version is 2.8.5), you'll find plenty of different download options at:

http://lynx.isc.org/
Lynx is also available for Mac OS X and various flavors of Windows, so even if you're not a hard-core Unix/Linux type, you can still reap most of the benefits of this terrific utility.

Eight Reasons to Love Lynx

1. Lynx is great for testing Web sites

Modern Web browsers can sometimes be too sophisticated, and there are also plenty of different browsers to worry about too, from Firefox to Camino, Safari to Internet Explorer. Underneath them all, though, it's the content that you want to come through properly, and Lynx is the Least Common Denominator of browsers. So it's safe to say -- if it renders reasonably well in a text-only world, and the site is readable and functional, it should be at least somewhat okay everywhere else.

Lynx is also good for reminding you what your site will look when you're on a cell-phone connection, since the current generation of cell-phone Web browsers render text only and barely understand line breaks, let alone anything more sophisticated. But previewing the page in a GUI-based browser makes it pretty difficult to know what's really going to happen.

2. Lynx shields you from suspicious site tricks

You're not too susceptible as a Linux user, but Web site owners nowadays have plenty of tricks up their sleeves to make your surfing experience less pleasant than it could be. From malicious spyware and viruses, to sneaky little JavaScript and ActiveX tricks that change your home page, resize your windows, pop up controlling windows that feed you additional adverts, and more, browsing the Web isn't as innocuous as it used to be. But Lynx shields you completely from this because it doesn't read the JavaScript code, doesn't accept or play ActiveX controls, shuns plug-ins, and ignores everything that's not simple, straightforward HTML.

3. Lynx is really, really fast

If you're used to working with graphical browsers, I guarantee you'll be blown away by just how fast a text-only browser is. Once you skip all the graphics, you find that the 40-100 connections needed to properly render a Web page in Firefox are reduced to one connection -- for the HTML content only -- in Lynx, and your browsing speed increases commensurately.

Many people who surf the Web looking for specific information find that Lynx and its text-only brethren help them search for and find what they seek quite a bit faster. There's a reason that Google is almost completely text-based too: it's delightfully fast (particularly compared to overblown ad-heavy monstrosities like MSN and Yahoo).

4. Lynx is disability-friendly

If you're reading this article with a Versabraille or some other device that helps you overcome a visual disability, you already know another great facet of Lynx -- it's disability-friendly in a way that no GUI-based browser can be. By its very nature, Lynx is designed for a keyboard-only interaction, with no pull-down menus, no pop-up windows, no mouse controls, and nothing to click on.

HTML 4.0 introduced quite a few new HTML capabilities for disabilities, but with all the market pressure to add flashy new features, precious few GUI-based browsers have implemented everything in the HTML 4.0 standard, and, no surprise, disability features appear to be last on the list. That's why the built-in support of Lynx for disabilities is such a winner.

5. Lets you ensure you're XHTML-compliant

This may seem a bit trivial, but if you're building Web sites, you should be obsessively ensuring that every graphic you reference also includes an ALT tag. There are two reasons for this: first, it's good coding style and a requirement of the new XHTML standard, but more importantly, it's a simple way to ensure that your site is disability-friendly. And an added bonus, if the sites you visit with Lynx have well-planned ALT tags then the browsing experience can be remarkably similar to a GUI-browser -- just a lot faster.

6. Lynx frees you from worrying about connection speeds

If you're not already paying a premium for high-speed broadband connectivity -- and even if you are -- there are fast connections and not so fast connections. And when you're on the road, even the best dial-up is, well, a dial-up connection. By using Lynx as your Web browser, you can ignore your connection speed, since the basic HTML page downloads in a flash even on the slowest connection!

7. Lynx lets you browse the Web from servers

I have a couple of different servers on which I host Web sites and other content, and sometimes it's just plain easier to use Lynx on the server, via an ssh or telnet connection. It's a great way to see what your server applications are seeing, too, if you're scripting or otherwise automating any Web interactivity.

8. Lynx is a fabulous tool for scripting Web interaction

I realize that as the author of Wicked Cool Shell Scripts and a 25-year veteran of the Unix command line, I might be a bit more enthusiastic about scripting and command lines than most people, but I have to say, Lynx is the secret ingredient behind dozens and dozens of my favorite tools and utilities.

Need a command-line tool to convert currencies? Want to have the current weather in Fiji listed when you log in rather than some crufty old fortune? Want to monitor a dozen RSS feeds for your name or your company? All of these can be easily accomplished by scripting Lynx.

Here's an easy example -- Google assigns each page in its index a "page rank", a value between 0 and 10 that indicates the relative importance (to Google) of the page. It's good to know your page rank because the higher it is, the more relevant your site will be for search results and the better traffic you'll get from people searching Google. You can ascertain the page rank of any given URL with the Google Toolbar, but it turns out various Web sites have figured out how to get the page rank with a simple CGI script call.

A Perfect Job for Lynx

Here's a tiny shell script that uses Lynx to feed in a URL and ascertain its page rank from the top25web.com form:

#!/bin/sh

echo -n "$1 page rank is"

echo "url=$1" |
    lynx -post_data "http://www.top25web.com/pagerank.php" | \
    grep "$1" | \
    cut -d: -f3-

exit 0
Easy enough! And with this called, say, "pagerank", you can easily ascertain the page rank of any page with:

$ pagerank http://www.intuitive.com/
http://www.intuitive.com/ page rank is 6/10
Really, the only limitation to scripting Lynx is your imagination. Anything you can find on the Web, anything you can get to come up in a browser, you can script with Lynx and some shell scripting tricks.

In Conclusion

I'll be honest with you -- I use Safari, Firefox, and, on rare occasions, Internet Explorer when I'm surfing the Web. But for scripting or testing sites, Lynx is a winner and a tremendous addition to your Linux toolkit. Don't leave home without it!

Dave Taylor is a long-time member of the Unix community, including having created the Elm Mail System and written a number of popular books on the subject including Teach Yourself Unix in 24 Hours and Wicked Cool Shell Scripts. You can find him online at: http://www.intuitive.com/.