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 

Site explorer

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


Joined: 11 Jun 2007
Posts: 5

PostPosted: Thu Jun 14, 2007 11:26 pm    Post subject: Site explorer Reply with quote

Hello I'm searching for a script, that searches a string on a webpage and posts it on my irc channel.

Example:
www.test.com/test.html looks like this:
Quote:
<html>
<body>
<h1>Animal Dog</h1>
</body>
</html>


# How to output the string? (It has to be $startstring)
When I use $text, it doesnt work!

My Starting:

Code:
package require http

bind pub - !searchstring searchproc

proc searchproc {nick uhost hand chan text} {
  set url "www.test.com/test.html"
  set token [::http::geturl $url]
  set content [::http::data $token]
  ::http::cleanup $content

regexp {<h1>$startstring(.*?)</h1>.*?} $fullcontent $stringcontent

if {[info exists $startstring]} {putserv "PRIVMSG $chan : String not found"}
else {putserv "PRIVMSG $chan : $stringcontent} }


So, my problem is how to tell the script to give out the string_search_text.
How can I do that?
Back to top
View user's profile Send private message
rosc2112
Revered One


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

PostPosted: Fri Jun 15, 2007 6:40 am    Post subject: Reply with quote

You cant use variables within the regexp like that, although you can use a form like:
Code:

set regexvar "h1>$startstring(.*?)</h1>.*?"

regexp $regexvar $content fullcontent stringcontent

That should work, assuming $startstring is actually defined (I don't see it defined in your code.)

Note also you made a mistake in using $fullcontent, $stringcontent, instead of just 'fullcontent, stringcontent' in your regexp and you also forgot to put in the $content var.

Actually, now that I look again, your code doesn't make much sense.. The stuff between () in the regexp, is what's going to be captured into $stringcontent. I'm assuming your $startstring is some other content you do *not* want to capture..

If you simply want to capture the entire content between <h1> </h1> then use:

regexp {<h1>(.*?)</h1>} $content fullcontent stringcontent
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