| View previous topic :: View next topic |
| Author |
Message |
TommyGun Voice

Joined: 26 May 2006 Posts: 36 Location: The Netherlands
|
Posted: Sat May 27, 2006 12:09 pm Post subject: Read xml file |
|
|
Hello
I already searcht for parse website but didnt found usefull scripts.
So my question;
Is there a script to parse php files? So i typ !ud an then it parses:
http://udstats.ict-universe.com/hitpara.php
Or aint this possible?
Thanks!
Last edited by TommyGun on Wed Jul 05, 2006 7:50 pm; edited 1 time in total |
|
| Back to top |
|
 |
krimson Halfop

Joined: 19 Apr 2006 Posts: 86
|
Posted: Sat May 27, 2006 12:41 pm Post subject: |
|
|
php code is parsed by the webserver's php interpretor and outputs html.
any html parser script would do. |
|
| Back to top |
|
 |
TommyGun Voice

Joined: 26 May 2006 Posts: 36 Location: The Netherlands
|
Posted: Mon May 29, 2006 4:01 pm Post subject: |
|
|
Ah i saw that the stats from the link from the startpost are also avaible in XML.
Example; http://tadah.mine.nu/xml/list.php?tabel=subteamoffset&prefix=rah&team=%5BDPC%5DDivision_Brabant&datum=2006-05-29
I found a script;
| Code: | package require http
bind pub - !test foo
proc foo {n u h c t} {
set x [::http::geturl http://bar.com/moo.txt]
foreach e [split [::http::data $x] \n] {puthelp "privmsg $c :$e"}
::http::cleanup $x
} |
But then i get this;
| Code: | -TommyBOT- <?xml version="1.0"?>
-TommyBOT- <list>
-TommyBOT- <listsize>30</listsize>
-TommyBOT- <offset>0</offset>
-TommyBOT- <flushlist>
-TommyBOT- <user>
-TommyBOT- <name>OldButNotSoWise</name>
-TommyBOT- <rank>1</rank>
-TommyBOT- <flush>1062</flush> |
Etc etc. How can i fix that?
Thank you very much  |
|
| Back to top |
|
 |
TommyGun Voice

Joined: 26 May 2006 Posts: 36 Location: The Netherlands
|
Posted: Thu Jun 01, 2006 9:02 am Post subject: |
|
|
| Bump |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Thu Jun 01, 2006 12:09 pm Post subject: |
|
|
the http package, by default, pulls the html (xml) code
trimming the code to gather the parts you want is usually done with regexp
another way is to regsub out the code by using
| Code: | | regsub -all {<([^<])*>} $e {} e | before output
the regsub way will not format, and may give errors on empty $e |
|
| Back to top |
|
 |
TommyGun Voice

Joined: 26 May 2006 Posts: 36 Location: The Netherlands
|
Posted: Thu Jun 01, 2006 12:17 pm Post subject: |
|
|
How would the code looks like then?
Thanks |
|
| Back to top |
|
 |
TommyGun Voice

Joined: 26 May 2006 Posts: 36 Location: The Netherlands
|
Posted: Sun Jun 04, 2006 6:29 pm Post subject: |
|
|
I tried to just place it somewhere in the code but that doesnt work
Maybe u can help? |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Sun Jun 04, 2006 6:46 pm Post subject: |
|
|
| Code: | foreach e [split [::http::data $x] \n] {
regsub -all {<([^<])*>} $e {} e
puthelp "privmsg $c :$e"
} |
|
|
| Back to top |
|
 |
TommyGun Voice

Joined: 26 May 2006 Posts: 36 Location: The Netherlands
|
Posted: Sun Jun 04, 2006 9:16 pm Post subject: |
|
|
Thanks for your help.
Now i have
| Code: | package require http
bind pub - !test
proc foo {n u h c t} {
set x [::http::geturl http://tadah.mine.nu/xml/list.php?tabel=subteamoffset&prefix=rah&team=%5BDPC%5DDivision_Brabant]
foreach e [split [::http::data $x] \n] {puthelp "privmsg $c :$e"}
regsub -all {<([^<])*>} $e {} e
puthelp "privmsg $c :$e"
} |
But i still get the same output. Am i doing someting wrong?
Sorry for my nooby  |
|
| Back to top |
|
 |
DragnLord Owner

Joined: 24 Jan 2004 Posts: 711 Location: C'ville, Virginia, USA
|
Posted: Sun Jun 04, 2006 10:00 pm Post subject: |
|
|
you left the old
| Code: | | foreach e [split [::http::data $x] \n] {puthelp "privmsg $c :$e"} | in there, you should have changed it with what I gave you |
|
| Back to top |
|
 |
TommyGun Voice

Joined: 26 May 2006 Posts: 36 Location: The Netherlands
|
Posted: Mon Jun 05, 2006 9:44 am Post subject: |
|
|
I did forget to say that;
| Code: | package require http
bind pub - !test
proc foo {n u h c t} {
set x [::http::geturl http://tadah.mine.nu/xml/list.php?tabel=subteamoffset&prefix=rah&team=%5BDPC%5DDivision_Brabant]
foreach e [split [::http::data $x] \n] {
regsub -all {<([^<])*>} $e {} e
puthelp "privmsg $c :$e"
} |
Doesnt work. It says;
| Code: | [15:44] Tcl error in file 'TommyBOT.conf':
[15:44] missing close-brace
while executing
"proc foo {n u h c t} {
set x [::http::geturl http://tadah.mine.nu/xml/list.php?tabel=subteamoffset&prefix=rah&team=%5BDPC%5DDivision_Brabant]
forea..."
(file "TommyBOT.conf" line 1354)
[15:44] * CONFIG FILE NOT LOADED (NOT FOUND, OR ERROR)
[tommygun@server eggdrop]$
|
I don't see where it goes wrong. Thanks |
|
| Back to top |
|
 |
Sir_Fz Revered One

Joined: 27 Apr 2003 Posts: 3793 Location: Lebanon
|
Posted: Mon Jun 05, 2006 10:52 am Post subject: |
|
|
The error tells you what the problem is, look at the braces.
| Code: | package require http
bind pub - !test
proc foo {n u h c t} {
set x [::http::geturl http://tadah.mine.nu/xml/list.php?tabel=subteamoffset&prefix=rah&team=%5BDPC%5DDivision_Brabant]
foreach e [split [::http::data $x] \n] {
regsub -all {<([^<])*>} $e {} e
puthelp "privmsg $c :$e"
}
} |
_________________ Follow me on GitHub
- Opposing
Public Tcl scripts |
|
| Back to top |
|
 |
TommyGun Voice

Joined: 26 May 2006 Posts: 36 Location: The Netherlands
|
Posted: Mon Jun 05, 2006 12:55 pm Post subject: |
|
|
No errors anymore, but no text neither
<TommyGun> !test
<TommyGun> !test
<TommyGun> !test
 |
|
| Back to top |
|
 |
TommyGun Voice

Joined: 26 May 2006 Posts: 36 Location: The Netherlands
|
Posted: Mon Jun 12, 2006 12:04 pm Post subject: |
|
|
| bump |
|
| Back to top |
|
 |
deadite66 Halfop
Joined: 30 May 2005 Posts: 74 Location: Great Yarmouth, UK
|
Posted: Tue Jun 13, 2006 2:55 am Post subject: |
|
|
add foo on the end of the bind
| Code: | | bind pub - !test foo |
_________________ <- tcl newb |
|
| Back to top |
|
 |
|