All pastes #816977 Raw Edit

Someone

public text v1 · immutable
·published 2007-12-15 03:25 UTC
rendered paste body
on *:TEXT:*:#: { 
  if (http:// isin $1) {
    var %host, %get
    %host = $remove($1,http://)

    ;;if URL is top page of site, creates random char for sockname
    if ($gettok(%host,2-,47) == $null) { %get = $chr(146) }
    else { %get = $gettok(%host,2-,47) }

    %host = $gettok(%host,1,47)
    set %sock.ch #
    if (www != $left(%host,3)) { %host = www. $+ %host }
    set %sock.host %host
    msg # sockopen %get %host 
    sockopen %get %host 80
  }
}



on *:sockopen:*: {
  msg %sock.ch sockwrite -n $sockname GET / $+ $sockname HTTP/1.1
  if ($sockname == $chr(146)) { sockwrite -n $sockname GET / HTTP/1.1 }
  else { sockwrite -n $sockname GET / $+ $sockname HTTP/1.1 }
  sockwrite -n $socknate Host: %sock.host
  sockwrite -n $sockname Connection: Close
  sockwrite -n $sockname $crlf
}


on *:sockread:*:{ 
  sockread %sock
  var %title
  if (*<title>*</title>* iswm %sock) { 
    ;msg %sock.ch $remove(%sock,<title>,</title>)
    %title = $remove(%sock,<title>,</title>,$chr(9))
    msg %sock.ch %title
  }
}