initial commit master
initial commit

file:b/.gitignore (new)
--- /dev/null
+++ b/.gitignore
@@ -1,1 +1,3 @@
+node_modules
 
+

file:b/autovit.ro.js (new)
--- /dev/null
+++ b/autovit.ro.js
@@ -1,1 +1,30 @@
+var jsdom = require("jsdom");
 
+var SkipExternalResources = /(google|onap|brat|cloudfront|optimizely|facebook|7w\.ro|spring\.js)/i;
+
+function getPhoneNumber(url, callback) {
+    jsdom.env({
+        url : url,
+        scripts : ["http://code.jquery.com/jquery.js"],
+        features: {
+            FetchExternalResources: ["script"],
+            ProcessExternalResources: ["script"],
+            SkipExternalResources: SkipExternalResources
+        },
+        done : function (err, window) {
+            window.$(function(){
+                window.$('.spoiler').trigger('click');
+                setTimeout(function(){
+                    callback(url, window.$('.phone-number').html());
+                    window.close();
+                }, 3000);
+            });
+        }
+    });
+}
+
+var data = {};
+getPhoneNumber('http://autovit.ro/anunt/mercedes-benz-a-classe-a-ID7GfMJ1.html', function(url, number){
+    data[url] = number;
+    console.log(data);
+});

file:b/olx.ro.js (new)
--- /dev/null
+++ b/olx.ro.js
@@ -1,1 +1,30 @@
+var jsdom = require("jsdom");
 
+var SkipExternalResources = /(google|onap|brat|cloudfront|optimizely|facebook|7w\.ro|spring\.js)/i;
+
+function getPhoneNumber(url, callback) {
+    jsdom.env({
+        url : "http://olx.ro/oferta/vand-capac-motor-mercury-6-hp-4-t-ID5vCqY.html",
+        scripts : ["http://code.jquery.com/jquery.js"],
+        features: {
+            FetchExternalResources: ["script"],
+            ProcessExternalResources: ["script"],
+            SkipExternalResources: SkipExternalResources
+        },
+        done : function (err, window) {
+            window.$(function(){
+                window.$('.link-phone').trigger('click');
+                setTimeout(function(){
+                    callback(url, window.$('.contactbox-indent .xx-large').html());
+                    window.close();
+                }, 3000);
+            });
+        }
+    });
+}
+
+var data = {};
+getPhoneNumber('http://autovit.ro/anunt/mercedes-benz-a-classe-a-ID7GfMJ1.html', function(url, number){
+    data[url] = number;
+    console.log(data);
+});

file:b/package.json (new)
--- /dev/null
+++ b/package.json
@@ -1,1 +1,15 @@
+{
+  "name": "olx.ro/autovit.ro phone number fetcher",
+  "version": "0.0.1",
+  "description": "fetches phone numbers hidden behind 'click to get number'",
+  "dependencies": {
+    "jsdom": "^7.2.2"
+  },
+  "devDependencies": {},
+  "scripts": {
+    "test": "echo \"Error: no test specified\" && exit 1"
+  },
+  "author": "",
+  "license": "ISC"
+}
 

comments