| View previous topic :: View next topic |
| Author |
Message |
spankymcfresh Voice
Joined: 20 Sep 2006 Posts: 2
|
Posted: Wed Sep 20, 2006 5:23 pm Post subject: Script to pubmsg webpage titles from pasted urls |
|
|
Anyone know of a simple script that will just publicly message the titles of urls pasted in a channel?
Thanks! :oops: |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Wed Sep 20, 2006 8:04 pm Post subject: |
|
|
I've posted several sample scripts on how to retrieve data from webpages, like:
http://forum.egghelp.org/viewtopic.php?p=64426#64426
You'd just be regexp searching for | Code: | | {<title>(.*?)</title>} |
Ohh, and using $text as the $url (which could be slightly dangerous allowing users to inject their own strings/urls into that...) |
|
| Back to top |
|
 |
spankymcfresh Voice
Joined: 20 Sep 2006 Posts: 2
|
Posted: Thu Sep 21, 2006 9:26 am Post subject: |
|
|
That is exactly what I wanted but wasn't searching for the right key words. Thanks!
I'm not sure how cpu intensive this will be, but I've changed it so that it scans everything said and runs the procedure. This appears to work for triggering without a space/keyword bind, though it strikes me as a nasty way to go about it. Any ideas anyone?
| Code: |
putlog "loaded: url.tcl (lists url titles from channel - thanks to rosc2112)"
package require http 2.3
bind pubm - * webcheck
proc webcheck {nick uhost hand chan text} {
foreach i $text {
if {([string match "*http://*" $i]) || ([string match "*www.*" $i])} {
set url [string trim $i]
set url [split $url]
regsub -all {http://+} $url "" url
catch {set page [::http::geturl $url -timeout 90000]} error
set html [::http::data $page]
::http::cleanup $page
foreach line {[split $html \n]} {
if {[regexp -nocase {<title>(.*?)</title>} $html match titlematch]} {
regsub -all {&+} $titlematch "&" titlematch
if { ([string match "*302*" $titlematch])} {
} else {putserv "PRIVMSG $chan :^BURL title:^B [join $titlematch]" }
}}
}
}
}
|
|
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
|
| Back to top |
|
 |
|