| View previous topic :: View next topic |
| Author |
Message |
FcLan Halfop
Joined: 30 Sep 2005 Posts: 64 Location: Poland
|
Posted: Fri Dec 16, 2005 8:54 am Post subject: help simple |
|
|
Hi i wrote a script which check my postion in some ranking imy id is 582 so url is: puts $sock "GET /index.php?site=online_segastatpers&uid=582
but i want if someone type !my_id example: !566 it will change url to 566 id:
puts $sock "GET /index.php?site=online_segastatpers&uid=566 and tell a place for this id it is a script:
| Code: |
set url "www.sensiblesoccer.de"
proc get_projects {nick uhost handle channel text} {
global url
set sock [socket $url 80]
fconfigure $sock -buffering line -buffersize 1000
puts $sock "GET /index.php?site=online_segastatpers&uid=582 HTTP/1.0"
puts $sock "Host: www.sensiblesoccer.de"
puts $sock ""
puts $sock "User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)"
flush $sock
while {![eof $sock]} {
gets $sock body
regexp -all {<td width="65%" class="medium">(.*?)</td><td} $body _ served
}
if {[eof $sock]} { close $sock }
regsub -all {(<.+?>)} $served "" served
puthelp "PRIVMSG $channel :[lindex $served]"
}
bind pub - !projects get_projects |
|
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Fri Dec 16, 2005 11:28 pm Post subject: |
|
|
ever heard of Tcl's http package? _________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
FcLan Halfop
Joined: 30 Sep 2005 Posts: 64 Location: Poland
|
Posted: Sat Dec 17, 2005 12:30 pm Post subject: |
|
|
| Yes, but i can`t understand it.. its too much easier on socks |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Sat Dec 17, 2005 1:07 pm Post subject: |
|
|
I'd bet you haven't bothered to even read Tcl doc page about http package, let alone judging it against raw sockets
and if you really have read it and couldn't understand it - while you understand sockets - there is something wrong with you, since it's really simpler than sockets - to understand and to use _________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
FcLan Halfop
Joined: 30 Sep 2005 Posts: 64 Location: Poland
|
Posted: Sat Dec 17, 2005 2:24 pm Post subject: |
|
|
Ok I`ve read something about it and imo all is ok: Tell me why this one dont works....
| Code: | bind pub - !news newscheck
proc newscheck {nick host hand chan text} {
set url "www.sensiblesoccer.de/index.php?lng=en"
set counter 0
set http(-useragent) {Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)}
set limit "4"
catch { set connection [http::geturl $url -timeout 3000] } error
if {[string match -nocase "*::http::*" $error]} {
set source [http::data $connection];http::cleanup $connection
set source [string map -nocase {"|"} $source]
foreach line [split $source |] {
if {[regexp {(.*?)} $line tmp lines ]} {
regexp {<td class="medium"><b class="marker">(.*?)</font></td>} $lines tmp titel
putserv "PRIVMSG $chan :$titel"
incr counter
}
if {$counter == $limit} {unset counter;return 0}
}
}
} |
Last edited by FcLan on Sat Dec 17, 2005 4:44 pm; edited 1 time in total |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Sat Dec 17, 2005 3:58 pm Post subject: |
|
|
learn how to post first - meaning posting code within [code] tags and explaining in details what the problem is, providing detailed log and error traceback; then I might tell you _________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
FcLan Halfop
Joined: 30 Sep 2005 Posts: 64 Location: Poland
|
Posted: Sat Dec 17, 2005 4:45 pm Post subject: |
|
|
Oh, sorry i forgot, btw. I know about it  |
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Sat Dec 17, 2005 9:21 pm Post subject: |
|
|
| Quote: |
...AND explaining in details what the problem is, providing detailed log and error traceback
|
_________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
FcLan Halfop
Joined: 30 Sep 2005 Posts: 64 Location: Poland
|
Posted: Sun Dec 18, 2005 6:58 am Post subject: |
|
|
| Bot do not sends any msg |
|
| Back to top |
|
 |
Alchera Revered One

Joined: 11 Aug 2003 Posts: 3344 Location: Ballarat Victoria, Australia
|
Posted: Sun Dec 18, 2005 7:45 am Post subject: |
|
|
Try
.. and paste what you get; also read what is in your bots own log and paste any relevant info. _________________ Add [SOLVED] to the thread title if your issue has been.
Search | FAQ | RTM |
|
| Back to top |
|
 |
FcLan Halfop
Joined: 30 Sep 2005 Posts: 64 Location: Poland
|
Posted: Sun Dec 18, 2005 8:16 am Post subject: |
|
|
I can`t understand:
| Code: | set source [string map -nocase {"|"} $source]
foreach line [split $source |] {
if {[regexp {(.*?)} $line tmp lines ]} { |
|
|
| Back to top |
|
 |
demond Revered One

Joined: 12 Jun 2004 Posts: 3073 Location: San Francisco, CA
|
Posted: Sun Dec 18, 2005 12:48 pm Post subject: |
|
|
you can't understand what you wrote yourself? not that's weird...
I already told you (or was it another guy...) to skip async processing for now and try just basic blocking mode - that is, remove -command switch from [geturl]
start with the simplest thing - fetch google's homepage:
| Code: |
package require http
set t [::http::geturl http://www.google.com]
::http::data $t
::http::cleanup $t
|
examine the structure of the page you need to parse by using appropriate tool (for example, DOM Inspector of Mozilla/Firefox); once you have a clear idea what that structure is, go for the parsing - 1. learn regexps and 2. learn from decent HTML parsing scripts, for example incith's or rssnews _________________ connection, sharing, dcc problems? click <here>
before asking for scripting help, read <this>
use [code] tag when posting logs, code |
|
| Back to top |
|
 |
FcLan Halfop
Joined: 30 Sep 2005 Posts: 64 Location: Poland
|
Posted: Wed Dec 21, 2005 9:46 am Post subject: |
|
|
| I don`t understand.. I need a simple example script and I will understand it |
|
| Back to top |
|
 |
caesar Mint Rubber

Joined: 14 Oct 2001 Posts: 3741 Location: Mint Factory
|
Posted: Wed Dec 21, 2005 5:05 pm Post subject: |
|
|
| demond wrote: |
start with the simplest thing - fetch google's homepage:
| Code: |
package require http
set t [::http::geturl http://www.google.com]
::http::data $t
::http::cleanup $t
|
|
isn't that a simple script?  _________________ Once the game is over, the king and the pawn go back in the same box. |
|
| Back to top |
|
 |
FcLan Halfop
Joined: 30 Sep 2005 Posts: 64 Location: Poland
|
Posted: Thu Dec 22, 2005 5:53 am Post subject: |
|
|
| yes, but where is regexps, and msg to channel?? |
|
| Back to top |
|
 |
|