egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Script to pubmsg webpage titles from pasted urls

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
spankymcfresh
Voice


Joined: 20 Sep 2006
Posts: 2

PostPosted: Wed Sep 20, 2006 5:23 pm    Post subject: Script to pubmsg webpage titles from pasted urls Reply with quote

Anyone know of a simple script that will just publicly message the titles of urls pasted in a channel?

Thanks! :oops:
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Wed Sep 20, 2006 8:04 pm    Post subject: Reply with quote

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
View user's profile Send private message
spankymcfresh
Voice


Joined: 20 Sep 2006
Posts: 2

PostPosted: Thu Sep 21, 2006 9:26 am    Post subject: Reply with quote

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 {&amp;+} $titlematch "&" titlematch
                      if { ([string match "*302*" $titlematch])} {
                    } else {putserv "PRIVMSG $chan :^BURL title:^B [join $titlematch]" }
                 }}
    }
    }
   }
Back to top
View user's profile Send private message
rosc2112
Revered One


Joined: 19 Feb 2006
Posts: 1454
Location: Northeast Pennsylvania

PostPosted: Thu Sep 21, 2006 7:53 pm    Post subject: Reply with quote

Take a look at the tinyurl script, that'll give you some ideas for using pubm for grabbing urls:

http://www.egghelp.org/cgi-bin/tcl_archive.tcl?mode=download&id=1259
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber