This was not the post I thought I was writing. But as blogging does, I went in to write one thing, and in looking for some information I was digging….

Not that I gaze at the blog stats a lot, but my post is will be about the silly posts that end up getting noticed (not that it is a goal).

So I went into the JetPack stats, and wound my way to the summary of top viewed posts, a screenshot shows it but is not useful. WHAT ABOUT THOSE LINKS!

Look at my stats! That’s all I can do, you can’t.

But it’s there in my Dashboard as a table. View Source… nope, it is some API / javascript / jquery / json / jujubee voodoo.

Here is a trick, in Chrome, I go to File -> Save As and use the option to save as Web Page Complete

What I get is an HTML file and all the other junk it needs to render on my browser as a local file, graphics, javascript, plus other crumbs and feathers.

A local copy of the stats page from my WordPress Dashboard

So I open the main HTML file and start looking to see how I can peel out the WordPress interface… nah, that’s convoluted. But I can see the entire HTML table of the part I want:

That’s my stats, in an HTML table!

In my text editor, the ever beloved BBEdit, I can click the sideways triangle and fold up that entire HTML table, and copy it. Boom!

One click and that 400+ row HTML table is neatly folded!

I paste that into a blank text document. There are a few rows I can see worth deleting, like the stats count for just the home page. I can, like above, find the <tr> row, fold it, and delete.

Then I notice something else I will need to change- that little icon for the stats next to the account? Well in my local saved archive, it references a local image file. This HTML will not work!

So I just find that image file in my archive, upload it to my server as http://cogdogblog.com/images/stats-icon.png. Then a global search for src="./Site Stats ‹ CogDogBlog — WordPress_files/stats-icon.png" and replace with src="http://cogdogblog.com/images/stats-icon.png".

I have an HTML table that is clean. I can then create a new page, and pop that HTML in it, Voila see the Top of the Dog House!

This is now a public page with real living links

Now this is all manual, and if Tom Woodward was here he would be tsk tsking me into fetching the live data… but for the purposes of that blog post, this is Good Enough.

And this is how I get distracted arou— oh wait what if I do a …..


Featured image: 2012-10-22 Digging a Hole flickr photo by Eselsmann™ shared under a Creative Commons (BY) license

Profile Picture for Alan Levine aka CogDog
An early 90s builder of the web and blogging Alan Levine barks at CogDogBlog.com on web storytelling (#ds106 #4life), photography, bending WordPress, and serendipity in the infinite internet river. He thinks it's weird to write about himself in the third person.

Comments

  1. Wait. I am here and I would never chastised you. I can barely spell the word. And there are few people on the internet who love hack-y solutions more than me.

    Jetpack sure does throw a metric ton of endpoints into your blog (check out http://cogdogblog.com/wp-json) but I don’t see any easy paths to the data after a quick skim. I see some stuff claiming stats_get_csv() works but my brief experminations 500’d my poor site.

    I think this points towards a more interesting API path but it’s raining and I’m a tired old man.

Leave a Reply

Your email address will not be published. Required fields are marked *