Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

Prelude: While this question is quite specific, I am also interested in how possible solutions could be generalized to other types of devices.

I have a HP Officejet Pro L7580 printer. One of the functions in the HP Solution Center software (that came with the printer) is an ability to get printer usage statistics. This is done by using the Solution Center GUI to select "myPrintMileage", which opens a web page that displays the printer usage stats in a graphical format.

The problem is that the graphics (bar charts, pie charts) are not very precise and none of the data is available for download. I would like to find an automated way of obtaining the information (using Perl, of course) so I can track it over time.

Possible approaches include:

  • Fully-automated
    1. Get the information directly from the printer via an API
    2. Use a HP utility as a proxy to call the (private?) API
  • Semi-automated
    1. Use a man-in-the-middle type program to intercept the call from myPrintMileage to the HP website
    2. Write a screen scraper to grab whatever data is available on the final page
  • Fully manual
    1. Manually record the information that is available on the final web page (yuk)

I have done quite a bit of searching to avoid reinventing the wheel. Unfortunately, I have not found any indication that the printer has a public API or that an HP client can be used as a proxy to interface with the printer. The few HP tools that I found (other than printer drivers) are targeted to the management of multiple printers and do not appear to meet my needs.

Since my initial attempt at finding a fully-automated approach failed, I looked behind door #2. Using Firefox's Live HTTP Headers extension I discovered that the myPrintMileage program makes a POST call to the HP website. The printer statistics are passed as an XML string (URL-encoded, of course). The data in the XML is much more precise and includes more information than what is displayed on the web page shown to the user.

Therefore, I beseech my fellow monks to meditate on the following:

  1. Is there a way to discover how the myPrintMileage program interfaces with the printer so I can make the call directly?
  2. Are there existing utilities that would allow me to get the printer stats directly from the printer? Am I reinventing the wheel?
  3. Is it feasible to attempt to intercept the POST call? (I believe this approach would require some manual intervention.)
  4. What other approaches should I consider?

I could write an XML parser for the POST content or a screen-scraper, but before I settle for a solution that is not fully automated I would like to get input from those wiser than I.

Many thanks.

Update: I suspect, but do not fully grok, how SNMP and/or MIB might apply.


In reply to Getting statistics from an attached device (printer) by bobf

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (9)
    As of 2021-01-20 23:21 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Notices?