Fixing the error “TypeError: ‘undefined’ is not a function (evaluating ‘globalScope[‘console’][‘log’].bind(globalScope[‘console’])’)”

Some libraries, like PDF.js, initialize their own logging function, which wraps console.log. If this runs in a context where function.bind does not exist, you’ll get the following error: TypeError: ‘undefined’ is not a function (evaluating ‘globalScope[‘console’][‘log’]. bind(globalScope[‘console’])’) Fixing this is actually quite simple- Mozilla provides a replacement function you can drop-in (not surprising, considering how […]

, ,

Scraping Adsense Ads with PhantomJS

PhantomJS is a headless WebKit, which lets you run Javascript in a browser from the command line. It adds additional API calls which facilitate automated testing, screenshots, and scraping. I thought it would be interesting to write a script to retrieve Adsense destination URLs and text with PhantomJS. Extracting advertisement blocks requires fairly simple CSS […]