I am attaching the saved html of a usage report. Basically, it gives you daily usage by date. I needed a better data like the accumulated usage for the month to date of subscription, AND the percentage of quota use ..etc..
I wrote jquery to do that. My first attempt is here:

var arr = {};
var duse;
var tday;
var usesofar=0;

$('#ctl00_ContentPlaceHolder1_TD_Unlimited_Usage_PerDay tr').each(function() {
    duse = $(this).find("td").eq(3).html();
    tday = $(this).find("td").eq(0).html();
           console.log(tday);
           console.log(duse);

           arr[tday] = duse;
});

$.each(arr, function (index, value) {
   //console.log( index + ' : ' + value );
  if(/GB/g.test(value)){usesofar += parseFloat(value);}

});
alert (usesofar);

I need your help in doing it right.

  1. This is a secured site I have to login.
  2. once I am in how can I use my jquery to display the report in a window.
  3. Is it possible to automate this proceedure and email me with the report ?

I did it in Perl but I feel jquery could be a better solution.. What do you think?

Dani AI

Generated

— good first pass extracting per-day values from the HTML; was right that an unattended, periodic email needs a session-capable fetcher rather than a purely in-browser action. Below are concise, practical paths and concrete pitfalls to watch for so the automation is reliable and safe.

A practical Perl pipeline: have a script that authenticates and fetches the protected report, parses the saved HTML into a DOM, normalizes units to a base (bytes), aggregates by billing period, formats a short report, and sends it by SMTP or an API. Use WWW::Mechanize or LWP::UserAgent for form login, fall back to WWW::Mechanize::Chrome or Selenium::Remote::Driver when the page is JS-driven, parse with Mojo::DOM or HTML::TreeBuilder::XPath, and send mail with Email::Sender::Simple or MIME::Lite. Schedule the script with a system scheduler (cron or systemd timer) so it runs unattended.

Parsing and aggregation notes: strip thousands separators, handle values like "N/A" or "Unlimited", and parse floats plus unit suffixes (KB/MB/GB). Decide whether to treat kilo as 1000 or 1024 and make that explicit (see binary prefixes). Use a robust date parser (for example the DateTime family) so month-to-date selection works when the report spans months or uses short date strings.

Security and testing: never hard-code credentials—use environment variables or a secrets store, test thoroughly against a saved HTML copy before scheduling, and respect the ISP terms of service (if login automation is disallowed, request an export or API). For JS-heavy sites where form POSTs fail, consider headless automation tools such as Puppeteer or Selenium.

Recommended Answers

All 2 Replies

You cannot purely do it from the client side (JQuery) if you need to read data from the server. Further more, you could use Ajax with JQuery, but you still need to implement authentication/authorization with your server.

If you already use Perl, keep using it. Web display is just a design. You could also implement a Perl script to generate a webpage for you anyway (but manually). It is better to do it that way. Yes, you can automate the email part using Perl as well. Just implement a Perl script that create & send an email to whatever email you want, leave it in your server, and then you could use cron to call the script for you.

Sorry for the delayed response, and thank you for your response. You are right; my approach is rather odd, and this is because I am new in the web design 'arena'...
If you have time to handhold me a bit, I still feel that it is possible to do it. In principle you receive a page and you want to massage it a bit. In my situation I am using Firefox and nothing else. Greasemonkey was created to do just that, I mean apply some javascript to get what you want from your local copy of the page. I can show you what I did so far, but if you have experience with this approach, or anyone reading this post; I can post the code. If I can show you that I can process the page and get the data I calculated; can you help me in automating it ?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.