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 

Data from web.

 
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests
View previous topic :: View next topic  
Author Message
iamdeath
Master


Joined: 11 Feb 2005
Posts: 323
Location: *HeLL*

PostPosted: Thu Apr 03, 2008 11:22 pm    Post subject: Data from web. Reply with quote

Hi guys, while using this proc in one of my script I am getting an error and I am confused how to get rid of it. I've tried all the possible ways I knew but I think I can't make it done without you guys help. Here is the code:

Code:
  proc your_callbackproc {sock} {
    global url nick2msg
    putlog "Getting scores on the request of $nick2msg"
    set headers [egghttp:headers $sock]
    set body [egghttp:data $sock]
    regsub -all "\n" $body "" body
    regsub -all -nocase {<br>} $body "<br>\n" body
    regsub -all {<b>} $body "\n\002" body
    regsub -all {</b>} $body "\002" body
    regsub -all {Cricinfo} $body "\00304#Cricket\003 @ \00304Undernet\003" body
    regsub -all {at } $body " at " body
    regsub -all {World Cup Warm-up Matches} $body "\00304,01World Cup Warm-up Matches\003" body
    regsub -all {<p class="blueBackHeading">} $body "\n\00300,12" body
    regsub -all {</p>} $body "\003\n" body
    regsub -all {&nbsp;} $body "" body
    regsub -all {This page automatically refreshes every 90 seconds.} $body "" body
    regsub -all {Scorecard} $body "" body
    regsub -all {Desktop scorecard} $body "" body
    regsub -all {Bulletin} $body "" body
    regsub -all {3D Animation} $body "" body
    regsub -all {Match home} $body "" body
    regsub -all {\|} $body {} body
    regsub -all {<.+?>} $body "" body

    [msgnick $body]
}


The error I am getting is:

Code:
[08:20] <Cricket`->  #Cricket @ Undernet - Desktop Scoreboard        function init(){   if(parent.adjustIFrameSize)       parent.adjustIFrameSize(window);      //alert(parent.adjustIFrameSize);}//window.onload = init;       
[08:20] <Cricket`->    Current time:   03:20 GMT, Fri Apr 04, 2008


The site I am using to fetch the data from is:

Code:
set url "http://content-pak.cricinfo.com/ci/engine/current/match/scores/liveframe.html"


Rest everything is working fine, below that error I am getting what I should, it works but just that function bla bla thingie bugs the crap out of me.

your help will be appreciated.

Thanks and peace
iamdeath
_________________
|AmDeAtH @ Undernet


Death is only the *Beginning*...
Back to top
View user's profile Send private message Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Thu Apr 03, 2008 11:43 pm    Post subject: Reply with quote

Code:
regsub -all -- {<script.*?>.*?</script>} $body "" body

It's the javascript. Strip it out as well with the above regsub. Place this regsub anywhere before this line: regsub -all {<.+?>} $body "" body
also on loading that page, appears it refreshes at 60 seconds.
Code:
regsub -all {This page automatically refreshes every 90 seconds.} $body "" body
You probably need to alter this as well. Wink
Back to top
View user's profile Send private message
iamdeath
Master


Joined: 11 Feb 2005
Posts: 323
Location: *HeLL*

PostPosted: Fri Apr 04, 2008 11:23 pm    Post subject: Reply with quote

Thanks alot, it works like a charm.. Thank you soo much. but I did'nt understand what you meant by your other suggestion, the 90 seconds thing.. can you tell me more about it if something is there, becuase that has no issues Smile


one more thing to ask you how to eliminate this type of error through regsub:

Code:
[08:26] <Cricket> <div style="float:left;padding-left:10px;">Developed by David Kendix</div>Last updated: Mar 22, 2008</div><div class="rankings_bottom_text">* The weighting of 'matches' is reduced over time so does not reflect the full number of matches played in the


I tried this but did'nt work:

Code:
regsub -all "<div style=\"float:left;padding-left:10px;\">" $info " " info


Thanks

peace
death
_________________
|AmDeAtH @ Undernet


Death is only the *Beginning*...
Back to top
View user's profile Send private message Visit poster's website
speechles
Revered One


Joined: 26 Aug 2006
Posts: 1398
Location: emerald triangle, california (coastal redwoods)

PostPosted: Sat Apr 05, 2008 12:36 am    Post subject: Reply with quote

Code:
regsub -all -- {<div .*?>} $body "" body
regsub -all -- {</div>} $body " " body

perhaps something like this? Wink


Not sure if by 'error' you mean: 1) just removing the html tags themselves, or 2) removing what is between the <div>...</div>

So the code above simply meets condition 1 above. Place it before this line: regsub -all {<.+?>} $body "" body Cool
Back to top
View user's profile Send private message
iamdeath
Master


Joined: 11 Feb 2005
Posts: 323
Location: *HeLL*

PostPosted: Sat Apr 05, 2008 12:39 am    Post subject: Reply with quote

Thanks alot speechless I will try your code too but this worked:

Code:
regsub -all "<div style=\"float:left;padding-left:10px;\">" $info " " info


The reason it was'nt working was because I was'nt putting it into the right place, but I will put your one too, that's short and better for div* type of errors..

Thanks speechless Very Happy

peace
death
_________________
|AmDeAtH @ Undernet


Death is only the *Beginning*...
Back to top
View user's profile Send private message Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    egghelp.org community Forum Index -> Script Requests All times are GMT - 4 Hours
Page 1 of 1

 
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