-
Notifications
You must be signed in to change notification settings - Fork 24
/
index.js
85 lines (76 loc) · 3.66 KB
/
index.js
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
var jsdom = require("jsdom");
var ProfileClass = require("./data-containers/profile"),
Experience = require("./data-containers/experience"),
Honors = require("./data-containers/honors"),
Project = require("./data-containers/projects"),
Education = require("./data-containers/education"),
Language = require("./data-containers/language");
function getProfile(linkedInURL, callback) {
jsdom.env({
url: linkedInURL,
scripts: ["http://code.jquery.com/jquery.js"],
done: function (errors, window) {
var $ = window.$;
var profile = new ProfileClass();
profile.publicProfileUrl = linkedInURL;
profile.name = $("#name h1 span span").text();
profile.pictureUrl = $(".profile-picture img").attr("src");
profile.headline = $("#headline p").text();
profile.location = $("#location dl dd span").text();
profile.summary = $(".summary .description").text();
profile.current = $("#overview-summary-current td ol li a").text();
$("#overview-summary-past td ol li").each(function () {
var company = $(this).text();
company = company.split(",")[0];
profile.past.push(company);
});
profile.education = $("#overview-summary-education td ol li").text();
$("#overview-summary-websites td ul li").each(function () {
profile.websites.push($(this).find("a[href]").attr("href"));
});
$("#background-experience div div").each(function () {
profile.positions.push(new Experience($(this).find("header h4").text(),
$(this).find("header h5 a").text(),
$(this).find(".experience-date-locale").clone().find(".locality").remove().end().text(),
$(this).find("span span.locality").text(),
$(this).find("p").html()
));
});
$("#background-honors div div div").each(function () {
profile.honors.push(new Honors($(this).find("h4 span").text(),
$(this).find("h5 span").text(),
$(this).find("> span").text(),
$(this).find("p").text()
));
});
$("#background-projects div div").each(function () {
profile.projects.push(new Project($(this).find("hgroup h4 a span:first").text(),
$(this).find("> span.projects-date").text(),
$(this).find("> p").text(),
$(this).find("hgroup h4 a[href]").attr("href")
));
});
$("#background-education div div div").each(function () {
profile.educations.push(new Education($(this).find("header h4").text(),
$(this).find("header h4 a[href]").attr("href"),
$(this).find("header h5 span.degree").text(),
$(this).find("header h5 span.major").text(),
$(this).find("header h5 span.grade").text(),
$(this).find("> span").text()
));
});
$("#skills-item .skill-pill a").each(function () {
profile.skills.push($(this).text());
});
$("#languages .section-item").each(function () {
var lang = $(this);
profile.languages.push(new Language(
lang.find("h4 span").text(),
lang.find(".languages-proficiency").text().toLowerCase()
));
});
callback(profile);
}
});
}
module.exports = getProfile;