Comparing version 0.0.1 to 0.0.2
@@ -1,1 +0,1 @@ | ||
'use strict';var _Promise='undefined'==typeof Promise?require('es6-promise').Promise:Promise,request=require('axios'),cheerio=require('cheerio'),moment=require('moment');function busy_hours(a,b){var c=require('@google/maps').createClient({key:b,Promise:_Promise}),d=function(a){return{hour:moment().hour(a[0]).format('HH'),percentage:a[1]}},e=function(a){if(a.data){var b=a.data,c=['APP_INITIALIZATION_STATE=','window.APP_FLAGS'],e=b.substring(b.lastIndexOf(c[0])+c[0].length,b.lastIndexOf(c[1])),f=eval(e),g=eval(f[3][6].replace(')]}\'','')),h=g[0][1][0][14][84];if(null===h)return{status:'error',message:'Place has no popular hours'};var i={status:'ok',week:Array.from(Array(7).keys()).map(function(a){return{day:moment().isoWeekday(a).format('ddd').toLowerCase(),hours:Array.from(h[0][a][1]).map(function(a){return d(a)})}})},j=h[7];return void 0!==j&&(i.now=d(j)),i}return{status:'error'}},f=function(a){var b=a.json.result.url;return b?request({url:b,headers:{"User-Agent":'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36'}}):{status:'error',message:'Invalid url'}},g=function(a){return{status:'error',message:a}},h=c.place({placeid:a},g).asPromise().then(f).then(e);return new _Promise(function(a){a(h)}).catch(g)}module.exports=busy_hours; | ||
'use strict';var _Promise='undefined'==typeof Promise?require('es6-promise').Promise:Promise,request=require('axios'),moment=require('moment');function busy_hours(a,b){var c=require('@google/maps').createClient({key:b,Promise:_Promise}),d=function(a){return{hour:moment().hour(a[0]).format('HH'),percentage:a[1]}},e=function(a){if(a.data){var b=a.data,c=['APP_INITIALIZATION_STATE=','window.APP_FLAGS'],e=b.substring(b.lastIndexOf(c[0])+c[0].length,b.lastIndexOf(c[1])),f=eval(e),g=eval(f[3][6].replace(')]}\'','')),h=g[0][1][0][14][84];if(null===h)return{status:'error',message:'Place has no popular hours'};var i={status:'ok',week:Array.from(Array(7).keys()).map(function(a){var b={day:moment().isoWeekday(a).format('ddd').toLowerCase(),hours:[]};return h[0][a]&&h[0][a][1]&&(b.hours=Array.from(h[0][a][1]).map(function(a){return d(a)})),b})},j=h[7];return void 0!==j&&(i.now=d(j)),i}return{status:'error'}},f=function(a){var b=a.json.result.url;return b?request({url:b,headers:{"User-Agent":'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.108 Safari/537.36'}}):{status:'error',message:'Invalid url'}},g=function(a){return{status:'error',message:a}},h=c.place({placeid:a},g).asPromise().then(f).then(e);return h}module.exports=busy_hours; |
{ | ||
"name": "busy-hours", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "Hacky web scraper for retrieving Google Places popular times data", | ||
@@ -23,3 +23,2 @@ "main": "./dist/index.js", | ||
"axios": "^0.17.1", | ||
"cheerio": "latest", | ||
"moment": "^2.20.1" | ||
@@ -26,0 +25,0 @@ }, |
Sorry, the diff of this file is not supported yet
80561
3
- Removedcheerio@latest
- Removedboolbase@1.0.0(transitive)
- Removedcheerio@1.0.0(transitive)
- Removedcheerio-select@2.1.0(transitive)
- Removedcss-select@5.1.0(transitive)
- Removedcss-what@6.1.0(transitive)
- Removeddom-serializer@2.0.0(transitive)
- Removeddomelementtype@2.3.0(transitive)
- Removeddomhandler@5.0.3(transitive)
- Removeddomutils@3.2.2(transitive)
- Removedencoding-sniffer@0.2.0(transitive)
- Removedentities@4.5.0(transitive)
- Removedhtmlparser2@9.1.0(transitive)
- Removediconv-lite@0.6.3(transitive)
- Removednth-check@2.1.1(transitive)
- Removedparse5@7.2.1(transitive)
- Removedparse5-htmlparser2-tree-adapter@7.1.0(transitive)
- Removedparse5-parser-stream@7.1.2(transitive)
- Removedsafer-buffer@2.1.2(transitive)
- Removedundici@6.21.1(transitive)
- Removedwhatwg-encoding@3.1.1(transitive)
- Removedwhatwg-mimetype@4.0.0(transitive)