Skip to content

Instantly share code, notes, and snippets.

@bkerley
Created September 30, 2008 16:01
Show Gist options
  • Save bkerley/13858 to your computer and use it in GitHub Desktop.
Save bkerley/13858 to your computer and use it in GitHub Desktop.
proc stock symbol {
set html [unescape_html_entities [wget http://finance.google.com/finance?q=$symbol]];
set cn [html [strip_html [lindex [regexp -all -inline {_companyName = '(.*?)'} $html] 1]]];
set curr [html [strip_html [lindex [regexp -all -inline {<span class="pr".*?>(.*?)<} $html] 1]]];
set chr [regexp -all -inline {<span class="ch[rg]".*?>(.*?)<} $html];
if {[lindex $chr 1] < 0} {set col red} else {set col green};
. "[bold]$curr[bold][color $col on white][html [strip_html [lindex $chr 1]]] [html [strip_html [lindex $chr 3]]][color] [color blue on white]$cn[color]"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment