| View previous topic :: View next topic |
| Author |
Message |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Tue Mar 13, 2007 9:42 pm Post subject: regsub problems. |
|
|
Hi, I have tried to write a code which will fetch cricket scores from a webpage and will show it to any channel.
The weblink of Score:
Scores
The regsub I am using:
| Code: |
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 {World Cup Warm-up Matches} $body "\00304,01World Cup Warm-up Matches\003" body
regsub -line {<p class="blueBackHeading">} $body "\n\00304,01" body
regsub -line {</p>} $body "\003\n" body
regsub -all {<.+?>} $body "" body
regsub -all { } $body "" body
regsub -all {This page automatically refreshes every 60 seconds.} $body "" body
regsub -all {Scorecard} $body "" body
regsub -all {Desktop scorecard} $body "" body
regsub -all {Bulletin} $body "" body
regsub -all {| |} $body "" body
|
The Reply I am getting:
| Code: |
[06:33] <Cricket`->
[06:33] <Cricket`-> Current time:01:33 GMT, Wed Mar 14, 2007
[06:33] <Cricket`-> 04,01One-Day Internationals
[06:34] <Cricket`-> 1st Match, Group D: West Indies v Pakistan at Kingston - Mar 13, 2007
[06:34] <Cricket`-> West Indies won by 54 runs
[06:34] <Cricket`-> West Indies 241/9 (50 ov); Pakistan 187 (47.2 ov) | | | | Standard Bank Pro20 Series
[06:34] <Cricket`-> Titans v Dolphins at Benoni - Mar 14, 2007
[06:34] <Cricket`-> Match scheduled to begin at 18:00 local time (16:00 GMT)
[06:34] <Cricket`-> Warriors v Lions at East London - Mar 14, 2007
[06:34] <Cricket`-> |
Need help:
1. I want to get rid of pipes " | "
2. You see that " Standard Bank Pro20 Series " is the heading it should come on a different line but it's not coming.
3. At the start and the end there is a blank space
4. The last line from the web the bot did'nt show.
Can you kindly help me out, I've tried to read regsub help alot but can't get outta it. Your help will be appreciated.
Thanks. |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Wed Mar 14, 2007 12:03 am Post subject: |
|
|
Why not use regexp to get the lines you DO want, instead of regsub'ing the junk you don't? Then you can put things into seperate vars, like for the titles and such. And then you can put your color codes into the var strings. You can use string trim to get rid of extra spaces..
| Code: |
regexp {<span.*?>Current time:</span>.*<span.*?>(.*?)</span>.*?<p class.*?>One-Day Internationals</p><p.*?>(.*?)</p>.*?<p.*?>Standard Bank Pro20 Series</p><p.*?>(.*?)</p>} body match date odiscores sbp20scores
#antiwordwrap---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|
That will put the relevant data into the vars called $date $odiscores and $sbp20scores. Then you can use regsub to get rid of \n, <b> and <br> (or use string map, either way you can put color codes in the strings if you want.)
The regexp hasn't been tested but should work. Read the regexp manpage, and notice the () parts are what are going to be put into the variable names. The var $match is the entire string. |
|
| Back to top |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Wed Mar 14, 2007 4:32 pm Post subject: |
|
|
| Thanks, I'll use and let you know if I have any problems.. |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Wed Mar 14, 2007 11:20 pm Post subject: |
|
|
I just noticed I had 'body' instead of $body in that example, should be
regexp {expression} $body match etc etc etc |
|
| Back to top |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Fri Mar 16, 2007 9:33 pm Post subject: |
|
|
Thanks for your kind, actually I have;nt yet got it done.. but I wanted to ask you if I only want to get ride of "|" can i get rid of them through regsub or regexp?..
Thanks |
|
| Back to top |
|
 |
rosc2112 Revered One

Joined: 19 Feb 2006 Posts: 1454 Location: Northeast Pennsylvania
|
Posted: Fri Mar 16, 2007 11:16 pm Post subject: |
|
|
Yes, regsub would work, but it would have to be escaped, as
regsub -all {\|} $varname {} varname |
|
| Back to top |
|
 |
iamdeath Master

Joined: 11 Feb 2005 Posts: 323 Location: *HeLL*
|
Posted: Sat Mar 17, 2007 8:36 am Post subject: |
|
|
Thanks alot
I am done with the pipes atleast  |
|
| Back to top |
|
 |
CuteBangla Halfop
Joined: 27 Feb 2006 Posts: 58 Location: Dhaka, Bangladesh
|
Posted: Sun Mar 18, 2007 7:44 am Post subject: |
|
|
| iamdeath wrote: | Thanks alot
I am done with the pipes atleast  |
will you share the working script with us plz _________________ SuMiT
iRC.CuteBangla.Com |
|
| Back to top |
|
 |
|