Get Title

By StaticX__ on Aug 18, 2008

--
It returns the title of the website you\'ve typed in a channel.
Syntax: !title website
Example: !title www.hawkee.com

:)

on *:TEXT:*:#:{
  if ($1 == !title) {
    if ( $2 ) {
      set %title_site $2
      set %title_chan $chan
      get_title $2
    }
    else { msg $chan Please Enter A WebSite }
  }
}

alias get_title {
  if ( $sock(get_title) == get_title ) {
    sockclose get_title
  }
  if ( !%title_site ) {
    echo -a Get title for: ?
  }
  else {
    sockopen get_title %title_site 80
  }
}

on *:sockopen:get_title:{
  if ($sockerr > 0) {
    echo -a Error: $sock(get_title).wsmsg
  }
  else {
    sockwrite -tn $sockname GET / HTTP/1.1    
    sockwrite -n $sockname Accept: */*
    sockwrite -tn $sockname User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.12) Gecko/20080201 Firefox/2.0.0.12 $+ $crlf
    sockwrite -n $sockname Host: %title_site
    sockwrite -n $sockname Connection: close
    sockwrite -n $sockname $crlf $+ $crlf
  }
}

on *:sockread:get_title:{
  if ($sockerr > 0) return
  sockread &get_titling
  if ($sockbr == 0) return -
  else {
    if ( $bfind(&get_titling,1,title) ) {
      set %start_pos $bfind(&get_titling,1,title)
      set %end_pos $bfind(&get_titling,$calc($bfind(&get_titling,1,title) + 5 ),title)
      set %now_this_is_title $remove($bvar(&get_titling,%start_pos,$calc(%end_pos - %start_pos)).text,title>,</)
      msg %title_chan Title for %title_site $+ : %now_this_is_title
      sockclose get_title
    }
  }
}

Comments

Sign in to comment.
Hawkee   -  Aug 18, 2008

Interesting concept, but I don't see a whole lot of value in it. Maybe this could be adapted to collect information on URL's mentioned in a channel in order to build a search engine bot.

 Respond  
Are you sure you want to unfollow this person?
Are you sure you want to delete this?
Click "Unsubscribe" to stop receiving notices pertaining to this post.
Click "Subscribe" to resume notices pertaining to this post.