#!/usr/bin/env tclsh set usage { usage: nasdaq.tcl symbol.. Retrieves current dividend data from nasdaq.com for the given ticker symbols, to stdout. } if {[llength $argv] < 1} {puts stderr $usage; exit 1} proc main argv { package require http package require tls http::register https 443 [list ::tls::socket -tls1 1] foreach symbol $argv {puts [nasdaq $symbol]} } proc nasdaq symbol { set sym [string tolower $symbol] ;# nasdaq.com wants lowercase set url https://www.nasdaq.com/de/symbol/$sym/dividend-history set token [http::geturl $url] set map {Date "" CashAmount div} set buf [list symbol $symbol] foreach line [split [set $token\(body)] \n] { if [regexp {_lastsale.+>[$](.+?)<} $line -> price] { lappend buf price $price } if [regexp {span.+Grid_([A-Za-z]+)_0.>(.+?)<} $line -> type val] { lappend buf [string map $map $type] $val } } return $buf } main $argvThe "nasdaq" function is at the core, and it may be helpful for other requirements, like computing the TTM or forward yield (to be done later). So far, you get only the raw data, like if you looked at their web page.Usage example:
~/Documents/onvista $ /c/Tcl/bin/tclsh ../../bin/nasdaq.tcl MO PM symbol MO price 63.2 exdate 13.09.2018 div 0.8 Decl 23.08.2018 Rec 14.09.2018 Pay 10.10.2018 symbol PM price 84.98 exdate 25.09.2018 div 1.14 Decl 12.09.2018 Rec 26.09.2018 Pay 12.10.2018
Jorge - 2018-10-09 19:48:07I am glad seeing a new post from you, I have learned a lot from your commented code. Thanks.
RS 2018-10-09: Thank you! Let's work together to build a useful toolbox for financial Tcl... :^)
JM 2018-10-09: yes! please let me know if there is anything I can do to help