All pastes #455369 Raw Edit

Miscellany

public text v1 · immutable
·published 2007-04-24 04:27 UTC
rendered paste body
alias weather {
  if ($1 == -s) {
    set %wzip $2-
    set %wway msg $active
    %wway opening socket - weather.com: $+ %wzip
    sockopen weather weather.com 80
  }
  else {
    set %wzip $1-
    set %wway echo -ta
    sockopen weather weather.com 80
  }
}
on *:sockopen:weather:{
  sockwrite -nt $sockname GET /weather/local/ $+ %wzip HTTP/1.1
  sockwrite -nt $sockname Host: http://weather.com
  sockwrite -nt $sockname $crlf
}
on *:sockread:weather:{
  if ($sockerr) {
    echo -ta Error: $sockerr
    halt
  }
  else {
    var %ee 
    sockread %ee
    if (*<B CLASS=obsTextA>Feels Like<BR> *&deg;F</B>* iswm %ee) {
      tokenize 32 %ee
      %wway $htmlfree($1-)
      sockclose weather
    }
  }
}
alias htmlfree { 
  var %x, %i = $regsub($1-,/(^[^<]*>|<[^>]*>|<[^>]*$)/g,$null,%x), %x = $remove(%x,&nbsp;) 
  return %x 
}