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.

simple question

Help for those learning Tcl or writing their own scripts.
Locked
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

simple question

Post by FcLan »

Code: Select all

package require http
bind pub - !news www:news
proc www:news {nick host handle chan text} {
   set data [http::data [http::geturl http://www.sensiblesoccer.de/index.php?lng=en]]
   regexp {<td class="medium"><b class="marker">(.*?)</font></td>} $data data match
   puthelp "PRIVMSG $chan :$match"

}
How to get for example frist 3 news not only 1? i tried set limit but dont works
User avatar
avilon
Halfop
Posts: 64
Joined: Tue Jul 13, 2004 6:58 am
Location: Germany

Post by avilon »

Code: Select all

package require http

bind pub - !news www:news

proc www:news {nick host handle chan text} {
	set token [::http::geturl http://www.sensiblesoccer.de/index.php?lng=en -timeout 10000]
	set status [::http::status $token]
	if {$status!="ok"} {
		switch -exact -- [string tolower $status] {
			reset   { puthelp "PRIVMSG $chan :error: server connection was reset." }
			timeout { puthelp "PRIVMSG $chan :error: server timeout (10 seconds)"   }
			default { puthelp "PRIVMSG $chan :unknown server error occured"      }
		}
		::http::cleanup $token; return
	}
	if {[::http::ncode $token]=="404"} {
		::http::cleanup $token
		puthelp "PRIVMSG $chan :Sorry, error 404"; return
	}
	set data [::http::data $token]; ::http::cleanup $token
	set all [regexp -all -inline -nocase -- {<td class="medium"><b class="marker">(.*?)</font></td>} $data]
	set count 1
	foreach {tmp title} $all {
		if {$count=="4"} {return}
		puthelp "PRIVMSG $chan :($count) $title"
		incr count
	}
}
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

Why

Code: Select all

puthelp "PRIVMSG $chan :($count) $title"
title?
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

And next question, why only 1 regexp works? if i try to use 2 or more don`t works ;/
User avatar
avilon
Halfop
Posts: 64
Joined: Tue Jul 13, 2004 6:58 am
Location: Germany

Post by avilon »

What's your problem? The script is faultless, isn't it?
User avatar
De Kus
Revered One
Posts: 1361
Joined: Sun Dec 15, 2002 11:41 am
Location: Germany

Post by De Kus »

FcLan wrote:And next question, why only 1 regexp works? if i try to use 2 or more don`t works ;/
"doesnt work" is no error description and is useless to assisst you.
De Kus
StarZ|De_Kus, De_Kus or DeKus on IRC
Copyright © 2005-2009 by De Kus - published under The MIT License
Love hurts, love strengthens...
F
FcLan
Halfop
Posts: 64
Joined: Fri Sep 30, 2005 10:46 am
Location: Poland

Post by FcLan »

I want to use more than 1 regexp (if i use 2 or more script don`t works) I don`t want to download only frist news, I want to use a set limit "any_number" but dont works
User avatar
avilon
Halfop
Posts: 64
Joined: Tue Jul 13, 2004 6:58 am
Location: Germany

Post by avilon »

*sigh* Have you even tested my script?

e//:
(23:44:44) (@avilon) !news
(23:44:45) (+bot) (1) Eifel X-Mas PC Cup
(23:44:47) (+bot) (2) NEW: Comments
(23:44:49) (+bot) (3) Exclusive Interview with Jon Hare
That's what you requested.
Btw.: I can't believe you are not able to express yourself. 90% of your board postings contain nothing more than "dont works", never a specific error description..
I saw you asking the same questions on IRC for days, how about reading some tutorials and references, and trying to UNDERSTAND what people advice you.

This is my last post in this topic, use my script or continue asking unsubstantial questions.
Last edited by avilon on Sat Dec 31, 2005 6:54 pm, edited 2 times in total.
Locked