<commit_before>var nodeio = require('node.io')
var Job = {}

Job.name = "Google Nexus 4 Availability"
Job.msg = 'fetching from Play Store ...'
Job.enabled = true
Job.status = 'building'
Job.interval = 1000*60*5
Job.timestamp = ''
Job.func = function( callback ) {
	var job  = new nodeio.Job({
		input:	false,
		run:	function(){
			this.getHtml( 
				'https://play.google.com/store/devices/details?id=nexus_4_16gb',
				function( err, $ ) {
					if(err) {
						callback(err, null)
					} else {
						// this is fragile, because when it is available, this span doesn't exist!
						var t = $('span.hardware-price-description').fulltext
						callback( null, {
							msg: t,
							status: 'success',
							timestamp: new Date()
						})
					}
				}
			)
		}
	})
	
	nodeio.start( job, { silent: true })
}
module.exports = Job
<commit_msg>Catch scraping errors<commit_after>var nodeio = require('node.io')
var Job = {}

Job.name = "Google Nexus 4 Availability"
Job.msg = 'fetching from Play Store ...'
Job.enabled = true
Job.status = 'building'
Job.interval = 1000*60*5
Job.timestamp = ''
Job.func = function( callback ) {
	var job  = new nodeio.Job({
		input:	false,
		run:	function(){
			this.getHtml( 
				'https://play.google.com/store/devices/details?id=nexus_4_16gb',
				function( err, $ ) {
					if(err) {
						callback(err, {
							msg: err,
							status: 'failure',
							timestamp: new Date()
						})
					} else {
						// this is fragile, because when it is available, this span doesn't exist!
						var available = false
						try {
							$('form#buy-hardware-form').each( function (form) {
								available = true
							})
						} catch( err ) {
							console.log( "Error getting form selector: " + err )
						}
						callback( null, {
							msg: ( available ) ? "Available" : "Sold out",
							status: 'success',
							timestamp: new Date()
						})
					}
				}
			)
		}
	})
	
	nodeio.start( job, { silent: true })
}
module.exports = Job

{'fraction_non_alphanumeric': 0.14779075672930422, 'fraction_numerical': 0.0111731843575419, 'mean_word_length': 2.402417962003454, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3911740', 'n_tokens_mistral': 885, 'n_tokens_neox': 650, 'n_words': 167}