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.

Read xml file

Requests for complete scripts or modifications/fixes for scripts you didn't write. Response not guaranteed, and no thread bumping!
User avatar
TommyGun
Voice
Posts: 36
Joined: Fri May 26, 2006 6:11 pm
Location: The Netherlands
Contact:

Read xml file

Post by TommyGun »

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.
User avatar
krimson
Halfop
Posts: 86
Joined: Wed Apr 19, 2006 8:12 am

Post by krimson »

php code is parsed by the webserver's php interpretor and outputs html.

any html parser script would do.
User avatar
TommyGun
Voice
Posts: 36
Joined: Fri May 26, 2006 6:11 pm
Location: The Netherlands
Contact:

Post by TommyGun »

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 ... 2006-05-29

I found a script;

Code: Select all

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: Select all

-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 :)
User avatar
TommyGun
Voice
Posts: 36
Joined: Fri May 26, 2006 6:11 pm
Location: The Netherlands
Contact:

Post by TommyGun »

Bump
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

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: Select all

regsub -all {<([^<])*>} $e {} e
before output
the regsub way will not format, and may give errors on empty $e
User avatar
TommyGun
Voice
Posts: 36
Joined: Fri May 26, 2006 6:11 pm
Location: The Netherlands
Contact:

Post by TommyGun »

How would the code looks like then?

Thanks
User avatar
TommyGun
Voice
Posts: 36
Joined: Fri May 26, 2006 6:11 pm
Location: The Netherlands
Contact:

Post by TommyGun »

I tried to just place it somewhere in the code but that doesnt work :lol:

Maybe u can help?
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

Code: Select all

foreach e [split [::http::data $x] \n] {
  regsub -all {<([^<])*>} $e {} e
  puthelp "privmsg $c :$e"
}
User avatar
TommyGun
Voice
Posts: 36
Joined: Fri May 26, 2006 6:11 pm
Location: The Netherlands
Contact:

Post by TommyGun »

Thanks for your help.

Now i have

Code: Select all

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 :lol:
User avatar
DragnLord
Owner
Posts: 711
Joined: Sat Jan 24, 2004 4:58 pm
Location: C'ville, Virginia, USA

Post by DragnLord »

you left the old

Code: Select all

   foreach e [split [::http::data $x] \n] {puthelp "privmsg $c :$e"} 
in there, you should have changed it with what I gave you
User avatar
TommyGun
Voice
Posts: 36
Joined: Fri May 26, 2006 6:11 pm
Location: The Netherlands
Contact:

Post by TommyGun »

I did forget to say that;

Code: Select all

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: Select all

[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
User avatar
Sir_Fz
Revered One
Posts: 3794
Joined: Sun Apr 27, 2003 3:10 pm
Location: Lebanon
Contact:

Post by Sir_Fz »

The error tells you what the problem is, look at the braces.

Code: Select all

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"
 }
}
User avatar
TommyGun
Voice
Posts: 36
Joined: Fri May 26, 2006 6:11 pm
Location: The Netherlands
Contact:

Post by TommyGun »

No errors anymore, but no text neither ;)

<TommyGun> !test
<TommyGun> !test
<TommyGun> !test

:?:
User avatar
TommyGun
Voice
Posts: 36
Joined: Fri May 26, 2006 6:11 pm
Location: The Netherlands
Contact:

Post by TommyGun »

bump
d
deadite66
Halfop
Posts: 74
Joined: Mon May 30, 2005 2:49 am
Location: Great Yarmouth, UK

Post by deadite66 »

add foo on the end of the bind

Code: Select all

bind pub - !test foo
<- tcl newb
Post Reply