tvrsh website domain change i recode again this tcl
but i got 1 prob
# We cut only player names from table.
regexp {<tr class="odd">(.*?)<tr class="colhead">} $data "" data
regsub -all -- {</a></td>} $data "|" data
- Код: Выделить всё
11:27:52pm / * <user> !webby http://espnfc.com/match/_/id/362753 --regexp <tr class="odd">(.*?)<tr class="colhead">--
11:27:54pm / * <bot> regexp: does not match any html.
http://espnfc.com/match/_/id/362753 website
i need cut only player names from table.
tvrsh писал(а):Try this:
bind pub - !lineup lineuppp
proc lineuppp {nick uhost hand chan text} {
::http::config -urlencoding utf-8 -useragent "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30)"
set team_tok [::http::geturl "http://soccernet.espn.go.com/scores"]
set data [::http::data $team_tok]
::http::cleanup $team_tok
# Some regsubs to work with data. We get table with games and split every game by |.
regsub -all -- {^.*?<div class="group-set">} $data "" data
regsub -all -- {<div id="casterListener">.*?$} $data "" data
regsub -all -- {<div class="mod-header">|<td class="status">} $data "|" data
set match ""; set team1id ""; set team1name ""; set team2id ""; set team2name "";
# Here we watch every line of data, and if we find in it our $text we save match id in $match variable.
foreach line [split $data "|"] {
regexp {<a href="/team/_/id/(.*?)">(.*?)</a>.*?<a href="(.*?)">.*?<a href="/team/_/id/(.*?)">(.*?)</a>} $line "" team1id team1name matchid team2id team2name
if {[string match -nocase "*$text*" $team1name] || [string match -nocase "*$text*" $team2name]} {
set match $matchid
}
}
# If we get valid match id we open its page, if not we tell about this.
if {$match != ""} {
set team_tok [::http::geturl "http://soccernet.espn.go.com$match"]
set data [::http::data $team_tok]
::http::cleanup $team_tok
regexp {<title>(.*?)</title>} $data "" title
# Here we take teams lineup between "<h4>Teams</h4>" and "Substitutes".
regsub -all -- {^.*?<h4>Teams</h4>} $data "" data
regsub -all -- {Substitutes.*?$} $data "" data
# Team names.
regexp {<thead>(.*?)</thead>} $data "" thead
regsub -all -- {</th>} $thead "|" thead
regsub -all -- {\<[^\>]*\>} $thead "" thead
# 0 - leftteam, 1- rightteam, and $index is requested team index(0 or 1).
set z 0; set index ""
foreach team [split $thead "|"] {
if {$team == $text} {
set index $z
} else {
incr z
}
}
# We cut only player names from table.
regexp {<tr class="odd">(.*?)<tr class="colhead">} $data "" data
regsub -all -- {</a></td>} $data "|" data
# Split all players by | and if player tags match "text-align:left" that means this player from leftteam.
foreach player [split $data "|"] {
if {[string match "*text-align:left*" $player]} {
lappend teamleft "$player, "
} else {
lappend teamright "$player, "
}
}
# Delete all tags from player lists.
regsub -all -- {\<[^\>]*\>} $teamleft "" teamleft
regsub -all -- {\<[^\>]*\>} $teamright "" teamright
# Output to channel.
putserv "PRIVMSG $chan :$title"
# The requested lineup is the first to output.
if {$index == "0"} {
putserv "PRIVMSG $chan :[lindex [split $thead "|"] 0]: $teamleft"
putserv "PRIVMSG $chan :[lindex [split $thead "|"] 1]: $teamright"
} elseif {$index == "1"} {
putserv "PRIVMSG $chan :[lindex [split $thead "|"] 1]: $teamright"
putserv "PRIVMSG $chan :[lindex [split $thead "|"] 0]: $teamleft"
}
} else {
putserv "PRIVMSG $chan :I can't find any team by your request \'$text\'."
return 0
}
}