-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlinkedinscript.js
More file actions
63 lines (50 loc) · 1.19 KB
/
linkedinscript.js
File metadata and controls
63 lines (50 loc) · 1.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
var phantom = require('phantom');
var Linkedin = require('./page_objects/linkedin_profile.js');
var logger = require('./logger.js');
var q = require('q');
init();
function init(){
var systemInput = process.argv.slice(2);
phantom.create(function (ph) {
ph.createPage(function (page) {
page.includeJs('http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js', function() {
var profile = new Linkedin(page);
profile.login()
.then(function(result){
setTimeout(function(){
getResults(profile, systemInput, ph);
}, 3000);
}, function(){
logger.error({
error: 'Unable to login'
});
});
});
});
});
};
function getResults(profile, systemInput, ph){
if (systemInput.length > 0) {
getSingleResult(profile, systemInput.pop())
.then(function(){
getResults(profile, systemInput, ph);
});
} else {
ph.exit();
}
};
function getSingleResult(profile, profileUrl){
var deferred = q.defer();
profile.getJobTitle(profileUrl)
.then(function(results){
logger.info(results);
deferred.resolve();
}, function(){
logger.error({
profile: profileUrl,
error: 'No results'
});
deferred.resolve();
});
return deferred.promise;
};