Version 2 of w3m

Updated 2002-06-28 13:22:34

w3m [L1 ] is a text-mode browser. Sometimes when people think they want to do complicated stuff that involves invoking browsers and controlling them with OLE, COM, or CORBA, all they're really after is a bit of Web automation. w3m and Expect team up to provide that:

    #!/bin/sh
    # magic \
    exec expect "$0" "$@"

    proc w3m:start {uri} {
        uplevel 1 spawn w3m $uri
    }

    proc w3m:quit {} {
        send qy\r
        expect eof
    }

    proc w3m:field_after_label {lab val} {
        send g/$lab\r\t\r$val\r
    }

    proc w3m:next_field {val} {
        send \t
    }
    proc w3m:dump_file {name} {
        file delete $name
        send "S$name\r"
    }
    proc w3m:dump_source {name} {
        file delete $name
        send "\033s\001\013$name\r"
    }

    w3m:open http://wiki.tcl.tk/Recent
    w3m:dump_file ~/wiki/recent.txt
    w3m:quit
    exec mail -s "wiki news" [email protected] < ~/wiki/recent.txt

et cetera.

The advantage of this method is the following: programming the browser is very similar to how the page ls loaded; so, the script must expect some notification from lynx that it's ready to further input. In case of full-screen terminal application, it's not so so simple. But for w3m, there is no such problem.

A/AK