tvrsh need your help

Просьбы о написании новых скриптов или поиске уже существующих.

Модератор: Модераторы

tvrsh need your help

Сообщение EvilHeart » 27 сен 2011 01:12

tvrsh i need lineup football script can you help pls?

website : http://soccernet.espn.go.com/scores

like this
Код: Выделить всё
!lineup norwich
Norwich City: John Ruddy, Russell Martin, Leon Barnett, Marc Tierney, Kyle Naughton, Bradley Johnson, David Fox, Wesley Hoolahan, Anthony Pilkington, Elliott Bennett, Steve Morison
Sunderland: Simon Mignolet, Wes Brown, Titus Bramble, Kieran Richardson, John O'Shea, David Vaughan, Craig Gardner, Sebastian Larsson, Ahmed Elmohamady, Nicklas Bendtner, Stephane Sessegnon
EvilHeart
 
Сообщения: 42
Зарегистрирован: 28 апр 2011 21:29
Благодарил (а): 7 раз.
Поблагодарили: 0 раз.
Версия бота: Eggdrop 1.8

Re: tvrsh need your help

Сообщение tvrsh » 27 сен 2011 22:05

I dont know what is norwich and i cant see it in your link.
Have fun.
-
Получить помощь можно на каналах #egghelp в сети IrcNet.ru и #eggdrop в сети RusNet(Ключ канала eggdrop).
Перед созданием новой темы внимательно читайте Правила оформления топиков.
Аватара пользователя
tvrsh
 
Сообщения: 1230
Зарегистрирован: 19 авг 2008 16:55
Откуда: Russian Federation, Podolsk
Благодарил (а): 6 раз.
Поблагодарили: 130 раз.
Версия бота: Eggdrop 1.6.20+suzi

Re: tvrsh need your help

Сообщение EvilHeart » 27 сен 2011 22:20

norwich is a team in english primier leauge

and main
page http://soccernet.espn.go.com/scores
when i will trigger "!lineup RealMadrid" then the bot have to show 18:45 Real Madrid v Ajax Amsterdam " and have to open the page "18:45 Real Madrid v Ajax Amsterdam" match link = http://soccernet.espn.go.com/preview/_/id/331232 and the the current line up of the football team

Код: Выделить всё
Command : !lineup Real Madrid
bot output :
 Real Madrid: Iker Casillas, Ricardo Carvalho, Raphael Varane, Álvaro Arbeloa, Sergio Ramos, Xabi Alonso, Sami Khedira, Cristiano Ronaldo, Mesut Özil, Karim Benzema, Kaká
Ajax Amsterdam: Kenneth Vermeer, Jan Vertonghen, Toby Alderweireld, Vurnon Anita, Gregory Van Der Wiel, Theo Janssen, Christian Eriksen, Siem De Jong, Derk Boerrigter, Kolbeinn Sigthorsson, Miralem Sulejmani
EvilHeart
 
Сообщения: 42
Зарегистрирован: 28 апр 2011 21:29
Благодарил (а): 7 раз.
Поблагодарили: 0 раз.
Версия бота: Eggdrop 1.8

Re: tvrsh need your help

Сообщение EvilHeart » 01 окт 2011 22:01

not possible?

i mode 1 work matci id
Код: Выделить всё
12:04:22am / * <iRoc> !lineup 318426
12:04:25am / * <iB0T> Leicester City : Kasper Schmeichel , Paul Konchesky , Matthew Mills , Lee Peltier , Souleymane Bamba , Neil Danns , Lloyd Dyer , Gelson Fernandes , Andy King , Yuki Abi , Darius Vassell
12:04:26am / * <iB0T> Derby County : Frank Fielding , Gareth Roberts , Jason Shackell , John Brayford , Mark O'Brien , Ben Davies , Craig Bryson , Jeff Hendrick , Jamie Ward , Steve Davies , Lee Croft


i need to convert to team name
Код: Выделить всё
bind pub -!- !lineup lineuppp
proc lineuppp {nick uhost hand chan text} {
   set infoooo [lindex [split $text] 0]
   set lineup(page) http://soccernet.espn.go.com/gamecast/_/id/
   set t [::http::geturl "$lineup(page)$infoooo" -timeout 30000]
   set data [::http::data $t]
   ::http::cleanup $t
   
   putlog "$lineup(page)"
       
   set l [regexp -all -inline -- {<div class=".*?lineup">.*?<div .*?>.*?<div class=".*?"></div><h4>(.*?)</h4>.*?</div>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<div class=".*?lineup">.*?<div .*?>.*?<div class=".*?"></div><h4>(.*?)</h4>.*?</div>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>} $data]
   
   putlog "$l"         

   foreach {black a b c d e f g h i j k l m n o p q r s t u v w x} $l {

       set a [string trim $a " \n"]
       set b [string trim $b " \n"]
       set c [string trim [string map {{&nbsp;} {} {\n} {}} $c]]
       set d [string trim $d " \n"]
       set e [string trim [string map {{<p>} {   } {</p>} {   }} $e]]
       set f [string trim $f " \n"]
       set g [string trim $g " \n"]      
       set h [string trim $h " \n"]            
       set i [string trim $i " \n"]                  
       set j [string trim $j " \n"]    
       set k [string trim $k " \n"]    
       set l [string trim $l " \n"]
       set m [string trim $m " \n"]
       set n [string trim $n " \n"]
       set o [string trim $o " \n"]
       set p [string trim $p " \n"]
       set q [string trim $q " \n"]
       set r [string trim $r " \n"]
       set s [string trim $s " \n"]
      set t [string trim $t " \n"]
       set u [string trim $u " \n"]           
       set v [string trim $v " \n"]          
       set w [string trim $w " \n"]                
       set x [string trim $x " \n"]                

   putlog "$l"      
      
      
      regsub -all {\s+} $a { } a
      regsub -all {\s+} $b { } b
      regsub -all {\s+} $c { } c
      regsub -all {\s+} $d { } d
      regsub -all {\s+} $e { } e
      regsub -all {\s+} $f { } f      
      regsub -all {\s+} $g { } g
      regsub -all {\s+} $h { } h
      regsub -all {\s+} $i { } i
      regsub -all {\s+} $j { } j
      regsub -all {\s+} $k { } k
      regsub -all {\s+} $l { } l      
      regsub -all {\s+} $m { } m
      regsub -all {\s+} $n { } n
      regsub -all {\s+} $o { } o
      regsub -all {\s+} $p { } p   
      regsub -all {\s+} $q { } q
      regsub -all {\s+} $r { } r
      regsub -all {\s+} $s { } s
      regsub -all {\s+} $t { } t               
      regsub -all {\s+} $u { } u      
      regsub -all {\s+} $v { } v   
      regsub -all {\s+} $w { } w         
      regsub -all {\s+} $x { } x      

   putserv "PRIVMSG $chan :$a : $b , $c , $d , $e , $f , $g , $h , $i , $j , $k , $l "
   putserv "PRIVMSG $chan :$m : $n , $o , $p , $q , $r , $s , $t , $u , $v , $w , $x "   
         return 0
   }
   putserv "privmsg $chan :Sorry  $text not found"   
   
}
EvilHeart
 
Сообщения: 42
Зарегистрирован: 28 апр 2011 21:29
Благодарил (а): 7 раз.
Поблагодарили: 0 раз.
Версия бота: Eggdrop 1.8

Re: tvrsh need your help

Сообщение tvrsh » 04 окт 2011 11:14

Try this code, if its ok this must show you page title of match with requested team.

TCL: [ Скачать ] [ Скрыть ]
    # Here we configure our url connection.
    ::http::config -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">} $data "|" data

    set match ""

    # 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="/match/_/id/(.*?)">.*?<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/gamecast/_/id/$match"]  
        set data [::http::data $team_tok]
        ::http::cleanup $team_tok
        regexp {<title>(.*?)</title>} $data "
" title
        putserv "
PRIVMSG $chan :$title"
    } else {
        putserv "
PRIVMSG $chan :I cant find any team by your request \'$text\'."
        return 0
    }
Have fun.
-
Получить помощь можно на каналах #egghelp в сети IrcNet.ru и #eggdrop в сети RusNet(Ключ канала eggdrop).
Перед созданием новой темы внимательно читайте Правила оформления топиков.
Аватара пользователя
tvrsh
 
Сообщения: 1230
Зарегистрирован: 19 авг 2008 16:55
Откуда: Russian Federation, Podolsk
Благодарил (а): 6 раз.
Поблагодарили: 130 раз.
Версия бота: Eggdrop 1.6.20+suzi

Re: tvrsh need your help

Сообщение EvilHeart » 04 окт 2011 16:04

error
Код: Выделить всё
[08:03:59] Tcl error [line]: can't read "team1name": no such variable
EvilHeart
 
Сообщения: 42
Зарегистрирован: 28 апр 2011 21:29
Благодарил (а): 7 раз.
Поблагодарили: 0 раз.
Версия бота: Eggdrop 1.8

Re: tvrsh need your help

Сообщение tvrsh » 04 окт 2011 22:37

<tvrsh> !lineup Gillingham
<@bionic> Gamecast: Gillingham v Barnet - Johnstone's Paint Trophy - ESPN Soccernet

TCL: [ Скачать ] [ Скрыть ]
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
        putserv "PRIVMSG $chan :$title"
    } else {
        putserv "PRIVMSG $chan :I cant find any team by your request \'$text\'."
        return 0
    }
}
Have fun.
-
Получить помощь можно на каналах #egghelp в сети IrcNet.ru и #eggdrop в сети RusNet(Ключ канала eggdrop).
Перед созданием новой темы внимательно читайте Правила оформления топиков.
Аватара пользователя
tvrsh
 
Сообщения: 1230
Зарегистрирован: 19 авг 2008 16:55
Откуда: Russian Federation, Podolsk
Благодарил (а): 6 раз.
Поблагодарили: 130 раз.
Версия бота: Eggdrop 1.6.20+suzi

Re: tvrsh need your help

Сообщение EvilHeart » 04 окт 2011 22:44

work fine
but remove pls this
Код: Выделить всё
        regexp {<title>(.*?)</title>} $data "" title


and set
this

Код: Выделить всё
set l [regexp -all -inline -- {<div class=".*?lineup">.*?<div .*?>.*?<div class=".*?"></div><h4>(.*?)</h4>.*?</div>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<div class=".*?lineup">.*?<div .*?>.*?<div class=".*?"></div><h4>(.*?)</h4>.*?</div>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>.*?<p id="playerName-.*?" class="player-name"><a href=".*?"  target="_blank">(.*?)</a></p>} $data]


Код: Выделить всё
12:41:39am / * <iRoc> !lineup Gillingham
12:41:44am / * <***> Gillingham: Paulo Gazzaniga, Andy Frampton, Danny Jackman, Garry Richards, Matt Fish, Curtis Weston, Lewis Montrose, Luke Rooney, Frank Nouble, Jo Kuffour, Stefan Payne Subs: Ross Flitney, Callum Davies, Chris Whelpdale, Dennis Oli, Danny Kedwell
12:41:47am / * <**> Barnet: Liam O'Brien, Anwar Uddin, Gary Borrowdale, Clovis Kamdjo, Daniel Leach, Mark Hughes, Mark Marshall, Mark Byrne, Sam Deering, Izale McLeod, Charlie Taylor Subs: Dean Brill, Sam Cox, Nauro Vilhete, Steven Kabba, Lloyd Owusu
EvilHeart
 
Сообщения: 42
Зарегистрирован: 28 апр 2011 21:29
Благодарил (а): 7 раз.
Поблагодарили: 0 раз.
Версия бота: Eggdrop 1.8

Re: tvrsh need your help

Сообщение tvrsh » 05 окт 2011 11:47

Try this:
TCL: [ Скачать ] [ Скрыть ]
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
    }
}
Have fun.
-
Получить помощь можно на каналах #egghelp в сети IrcNet.ru и #eggdrop в сети RusNet(Ключ канала eggdrop).
Перед созданием новой темы внимательно читайте Правила оформления топиков.

За это сообщение автора tvrsh поблагодарил:
EvilHeart (28 июн 2013 21:39)
Аватара пользователя
tvrsh
 
Сообщения: 1230
Зарегистрирован: 19 авг 2008 16:55
Откуда: Russian Federation, Podolsk
Благодарил (а): 6 раз.
Поблагодарили: 130 раз.
Версия бота: Eggdrop 1.6.20+suzi

Re: tvrsh need your help

Сообщение EvilHeart » 06 окт 2011 08:51

10:50:06am / * <iRoc> !lineup Aurora
10:50:08am / * <****> ESPNSoccernet.com FILE NOT FOUND

can you change
Код: Выделить всё
set team_tok [::http::geturl "http://soccernet.espn.go.com$match"] 
to
set team_tok [::http::geturl "http://soccernet.espn.go.com/match/_/id/$match"] 
EvilHeart
 
Сообщения: 42
Зарегистрирован: 28 апр 2011 21:29
Благодарил (а): 7 раз.
Поблагодарили: 0 раз.
Версия бота: Eggdrop 1.8

Re: tvrsh need your help

Сообщение EvilHeart » 09 окт 2011 23:36

title work but lineup not work

1:34:24am / * <iRoc> !lineuppp Falkirk
1:34:26am / * <****> Match: Annan Athletic v Falkirk - Scottish League Challenge Cup - ESPN Soccernet

TCL: [ Скачать ] [ Скрыть ]
bind pub - !lineuppp 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/_/id/$match"]  
        set data [::http::data $team_tok]
        ::http::cleanup $team_tok

        set thead {}   
        #set awayLineup {}     

        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
    }
}
EvilHeart
 
Сообщения: 42
Зарегистрирован: 28 апр 2011 21:29
Благодарил (а): 7 раз.
Поблагодарили: 0 раз.
Версия бота: Eggdrop 1.8

Re: tvrsh need your help

Сообщение EvilHeart » 28 июн 2013 22:01

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:
TCL: [ Скачать ] [ Скрыть ]
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
    }
}
EvilHeart
 
Сообщения: 42
Зарегистрирован: 28 апр 2011 21:29
Благодарил (а): 7 раз.
Поблагодарили: 0 раз.
Версия бота: Eggdrop 1.8


Вернуться в Заявки на скрипты

Кто сейчас на конференции

Сейчас этот форум просматривают: нет зарегистрированных пользователей и гости: 2

cron