Skip to content
This repository has been archived by the owner on Nov 7, 2018. It is now read-only.

Commit

Permalink
update readme, add phantom script, original screengrabs
Browse files Browse the repository at this point in the history
  • Loading branch information
alykat committed Jan 24, 2016
1 parent 475b190 commit fe5a323
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 1 deletion.
18 changes: 17 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,29 @@ The morning of the January 2016 blizzard, my husband showed me Google Maps on hi

When we got home, I wrote a quick, crude [PhantomJS](http://phantomjs.org) script to take regular screenshots of Google Maps for the rest of the day. Then I selected the screenshots I wanted to use and turned them into a GIF using [ImageMagick](http://www.imagemagick.org/script/convert.php).

The final gif includes screengrabs taken roughly every half-hour. There's a gap between 2 and 4 p.m. (sadly, right about when the storm hits Washington, D.C., in earnest) when my script threw an error and I didn't notice.

This was a crude, pulled-together-in-10-min-or-so project, so nothing is done in a clean or optimized way. I'm saving it here on GitHub mostly for my own future reference.

----------

## Screencapture

The [PhantomJS](http://phantomjs.org) script (TK TK TK)
I wrote a crude [PhantomJS](http://phantomjs.org/screen-capture.html) script ([here it is](mapcapture.js)) to snap screengrabs of [Google Maps](https://www.google.com/maps/@38.6337794,-76.8123652,6z/data=!5m1!1e1) (for traffic) and [WNYC's weather radar](http://project.wnyc.org/storm-radar/) (which I didn't end up using) every 5 minutes or so. I added an extra 5-second delay to help make sure that all/most of the page had rendered before PhantomJS captured the image. Even then, about a fourth of my Google Maps screencaps came out mostly blank, with just the map search bar and other wrapper items and no actual map.

Most PhantomJS scripts include a `phantom.exit();` command somewhere. I excluded it because I wanted it to keep running until I cancelled it (ctrl-C) in terminal.

Since I already had npm on my machine, I used it to install PhantomJS:

```
npm install phantomjs
```

And to run my script:

```
phantomjs mapcapture.js
```

----------

Expand Down
49 changes: 49 additions & 0 deletions mapcapture.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
var intervalLength = 300000;

function screenCap() {
loadMap();
loadRadar();
}

function loadMap() {
var page = require('webpage').create();

page.viewportSize = {
width: 1200,
height: 1200
};

page.open('https://www.google.com/maps/@38.6337794,-76.8123652,6z/data=!5m1!1e1', function() {
map_wait();
});

function map_wait() {
setTimeout(function() {
var timestamp = (new Date()).toLocaleString();
page.render('screengrabs/map-' + timestamp + '.png');
}, 5000);
}
}

function loadRadar() {
var page = require('webpage').create();

page.viewportSize = {
width: 1200,
height: 1200
};

page.open('http://project.wnyc.org/storm-radar/', function() {
radar_wait();
});

function radar_wait() {
setTimeout(function() {
var timestamp = (new Date()).toLocaleString();
page.render('screengrabs/radar-' + timestamp + '.png');
}, 5000);
}
}

screenCap();
var interval = setInterval(screenCap, intervalLength);
Binary file added screengrabs/google-maps.zip
Binary file not shown.

0 comments on commit fe5a323

Please sign in to comment.