WebAdvisor

By Gecko321 on Jun 21, 2012

Based on FordLawnmower's version.

Will check all web addresses that are posted on a channel. Can change options on which ones to show.

package require http 
namespace eval webadvisor {
#Use lowercase letters only for this setting.
  variable showsafe "on"
  variable showwarning "on"
  variable showdanger "on"
}

bind pubm - "*" main

proc main {nick host hand chan text} { 
    if {[regexp {(www\.|http\:\/\/)([^\s]+)} [strip $text] a b site]} { putserv "PRIVMSG $chan :[resolve $site]" }
}

proc check {site} {
  set url "http://www.siteadvisor.com/sites/$site"
  set page [web2data $url]
  if {[regexp {class="siteGreen">} $page] && $webadvisor::showsafe == "on"} { return "(SAFE) No problems found with: $site"
  } elseif {[regexp {class="siteYellow">} $page] && $webadvisor::showwarning == "on"} { return "(CAUTION) Found potential suspicious behavior on: $site"
  } elseif {[regexp {class="siteRed">} $page] && $webadvisor::showdanger == "on"} { return "(DANGER) Found potential security risks with: $site" }
} 

proc resolve {site} {
  set url "http://$site"
  set page [web2data $url]
  if {$page == 0} { return }
  if {[string range $page 0 3] != "301"} { return [check $site]
  } elseif {[regexp {href="(.*?)">?i} $page match site]} { return [check $site]
  } elseif {[regexp {<html} $page]} { return [check $site] }
}

proc strip {text} { return [regsub -all -- {\017|\015|\031|\002|\037|\026|\003(\d{1,2})?(,\d{1,2})?} $text ""] }

proc web2data {website} {
    package require http
    if { [catch { set token [http::geturl $website -timeout 100000]} error] } { return 0
     } elseif { [http::ncode $token] == "404" } { return 0
     } elseif { [http::status $token] == "ok" } { set data "[http::ncode $token] [http::data $token]"
     } elseif { [http::status $token] == "timeout" } { return 0
     } elseif { [http::status $token] == "error" } { return 0 }
    http::cleanup $token
    if {[info exists data]} { return $data
    } else { return 0 }
}

putlog "WebAdvisor"

Comments

Sign in to comment.
BaileyBelmont   -  Mar 14, 2017

Great! It is much less and laconic than web crawlers "out of the box" It works just awesomely for my essay writing company

 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.