egghelp.org community Forum Index
[ egghelp.org home | forum home ]
egghelp.org community
Discussion of eggdrop bots, shell accounts and tcl scripts.
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

Read xml file
Goto page 1, 2  Next
 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
TommyGun
Voice


Joined: 26 May 2006
Posts: 36
Location: The Netherlands

PostPosted: Sat May 27, 2006 12:09 pm    Post subject: Read xml file Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
krimson
Halfop


Joined: 19 Apr 2006
Posts: 86

PostPosted: Sat May 27, 2006 12:41 pm    Post subject: Reply with quote

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

any html parser script would do.
Back to top
View user's profile Send private message Send e-mail
TommyGun
Voice


Joined: 26 May 2006
Posts: 36
Location: The Netherlands

PostPosted: Mon May 29, 2006 4:01 pm    Post subject: Reply with quote

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 Smile
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
TommyGun
Voice


Joined: 26 May 2006
Posts: 36
Location: The Netherlands

PostPosted: Thu Jun 01, 2006 9:02 am    Post subject: Reply with quote

Bump
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Thu Jun 01, 2006 12:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
TommyGun
Voice


Joined: 26 May 2006
Posts: 36
Location: The Netherlands

PostPosted: Thu Jun 01, 2006 12:17 pm    Post subject: Reply with quote

How would the code looks like then?

Thanks
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
TommyGun
Voice


Joined: 26 May 2006
Posts: 36
Location: The Netherlands

PostPosted: Sun Jun 04, 2006 6:29 pm    Post subject: Reply with quote

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

Maybe u can help?
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Sun Jun 04, 2006 6:46 pm    Post subject: Reply with quote

Code:
foreach e [split [::http::data $x] \n] {
  regsub -all {<([^<])*>} $e {} e
  puthelp "privmsg $c :$e"
}
Back to top
View user's profile Send private message
TommyGun
Voice


Joined: 26 May 2006
Posts: 36
Location: The Netherlands

PostPosted: Sun Jun 04, 2006 9:16 pm    Post subject: Reply with quote

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 Laughing
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
DragnLord
Owner


Joined: 24 Jan 2004
Posts: 711
Location: C'ville, Virginia, USA

PostPosted: Sun Jun 04, 2006 10:00 pm    Post subject: Reply with quote

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
View user's profile Send private message
TommyGun
Voice


Joined: 26 May 2006
Posts: 36
Location: The Netherlands

PostPosted: Mon Jun 05, 2006 9:44 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website MSN Messenger
Sir_Fz
Revered One


Joined: 27 Apr 2003
Posts: 3793
Location: Lebanon

PostPosted: Mon Jun 05, 2006 10:52 am    Post subject: Reply with quote

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
View user's profile Send private message Visit poster's website
TommyGun
Voice


Joined: 26 May 2006
Posts: 36
Location: The Netherlands

PostPosted: Mon Jun 05, 2006 12:55 pm    Post subject: Reply with quote

No errors anymore, but no text neither Wink

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

Question
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
TommyGun
Voice


Joined: 26 May 2006
Posts: 36
Location: The Netherlands

PostPosted: Mon Jun 12, 2006 12:04 pm    Post subject: Reply with quote

bump
Back to top
View user's profile Send private message Visit poster's website MSN Messenger
deadite66
Halfop


Joined: 30 May 2005
Posts: 74
Location: Great Yarmouth, UK

PostPosted: Tue Jun 13, 2006 2:55 am    Post subject: Reply with quote

add foo on the end of the bind

Code:
bind pub - !test foo

_________________
<- tcl newb
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Goto page 1, 2  Next
Page 1 of 2

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Forum hosting provided by Reverse.net

Powered by phpBB © 2001, 2005 phpBB Group
subGreen style by ktauber