This is the new home of the egghelp.org community forum.
All data has been migrated (including user logins/passwords) to a new phpBB version.


For more information, see this announcement post. Click the X in the top right-corner of this box to dismiss this message.

Site explorer

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
Post Reply
r
retan
Voice
Posts: 5
Joined: Mon Jun 11, 2007 11:10 pm

Site explorer

Post by retan »

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:
<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: Select all

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?
User avatar
rosc2112
Revered One
Posts: 1454
Joined: Sun Feb 19, 2006 8:36 pm
Location: Northeast Pennsylvania

Post by rosc2112 »

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

Code: Select all

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
Post Reply