Speedy Script Revisited

Di Artikel "Checking Speedy Usage Using XMLHttpRequest" yang terdahulu, masih belum dapat melihat besar usagenya. Untuk itu, script speedy.js saya revisi, meniru implementasi script speedy versi python, menggunakan regular expression. Bagi anda yang ngga pengen ngerti tentang teknisnya, langsung aja download Speedy Usage Script v2

Penggunaan regex memungkinkan proses parsing halaman HTML speedy menjadi lebih mudah dan cepat. Adapun yang saya ubah pada skrip speedy.js adalah hanya pada bagian parsing aja.

Line: 60-64

pos = body.indexOf('Sisa Limit');
pos = body.indexOf('Sisa Limit');
limit = body.substring(pos + 33, pos + 38);
pos = body.indexOf('Pemakaian</td>');
used = body.substring(pos + 32, pos + 37);
WScript.Echo("Speedy Usage For: " + username + "\\nSisa Limit: " + limit + "%\\nTerpakai  : " + used + " % " );

Ke:
re = new RegExp('<b>Pemakaian Speedy</b>(.*?)</TD>.*?' +
  '<td[^>]*>Pemakaian</td><td[^>]*>(.*?)</td>.*?' +
  '<td[^>]*>Pemakaian</td><td[^>]*>(.*?)</td>.*?' +
  '<td[^>]*>Limit</td><td[^>]*>(.*?)</td>.*?'+
  '<td[^>]*>Kelebihan</td><td[^>]*>(.*?)</td>', 'gi');
match = re.exec(body);
if (match && match.length >= 6) {
  str = "Pemakaian Speedy " + match[1].replace(/(<[^>]+>|&nbsp;)/gi, '') + "\\n";
  str += "Bandwidth: " + match[3] + "\\n";
  str += "Terpakai: " + match[2] + "\\n";
  str += "Limit: " + match[4] + "\\n";
  str += "Kelebihan: " + match[5] + "\\n";
  WScript.Echo(str);
}

3 komentar

  1. Aryo Sanjaya bilang:

    spidisax

    *belom ada jalur spidi ke joyogrand*

    April 17th, 2007 at 09:50
  2. JOKERz bilang:

    finally……… (^_^)

    April 24th, 2007 at 02:45
  3. Update SpeedyUsage Script | Ferdianto.com bilang:

    [...] Telkom ngerombak struktur website TelkomSpeedy.com. Jadi tool untuk ngecek usage speedy nya sempet ga jalan selama beberapa hari. Ditambah lagi dengan monitor saya yang wafat mulai awal [...]

    April 26th, 2007 at 23:16

Tinggalkan Komentar





*
To prove you're a person (not a spam script), type the security word shown in the picture. Click on the picture to hear an audio file of the word.
Click to hear an audio file of the anti-spam word