Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions lib/profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
var companyFactory = require('./company'),
experienceFactory = require('./experience'),
//Honors = require('./honors'),
//Project = require('./projects'),
projectFactory = require('./projects'),
educationFactory = require('./education'),
languageFactory = require('./language');

Expand All @@ -25,7 +25,7 @@ module.exports = function(window) {
websites: [],
positions: [],
//honors: [],
//projects: [],
projects: [],
educations: [],
skills: [],
languages: []
Expand All @@ -49,13 +49,10 @@ module.exports = function(window) {
// ));
//});
//
//$('#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')
// ));
//});

$('#projects .project').each(function () {
profile.projects.push(projectFactory($(this)));
});

$('#education .schools .school').each(function () {
profile.educations.push(educationFactory($(this)));
Expand Down
40 changes: 24 additions & 16 deletions lib/projects.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,25 @@
function Project(name, dates, description, projectlink) {
this.name = name;
this.dates = (function (dates) {
var dd = (~dates.indexOf('(') ? dates.substring(0, dates.indexOf('(')) : dates).split('–'),
current = dd[1] && ~dd[1].indexOf('Present') ? true : false;
'use strict';

return {
start: dd[0] ? new Date(dd[0]).toJSON() : undefined,
end: dd[1] && !current ? new Date(dd[1]).toJSON() : undefined,
current: current
};
})(dates);
this.description = description;
this.projectlink = projectlink;
}

module.exports = Project;
module.exports = function (project) {
return {
name: project.find('.item-title a').text(),
dates: (function (dates) {
var dd = dates.map(function(idx) {
if (typeof idx === 'number') {
return dates[idx].innerHTML.trim();
} else {
return undefined;
}
});
var current = !dd[1] || ~dd[1].toLowerCase().indexOf('present') ? true : false;
return {
start: dd[0] ? new Date(dd[0]).toJSON() : undefined,
end: dd[1] && !current ? new Date(dd[1]).toJSON() : undefined,
current: current
};
})(project.find('> span.projects-date time')),
description: project.find('.description').html(),
teamCount: project.find('.contributors .contributor').length,
projectlink: project.find('.item-title a[href]').attr('href')
};
};
14 changes: 7 additions & 7 deletions test/scraper-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,18 @@ describe('<LinkedIn Scraper>', function() {
function validateProfile(profile) {
should(profile).be.ok();
should(profile).have.property('name', 'Daniel Henrique Joppi');
should(profile).have.property('headline', 'Software Architect na Rospo GeoTech');
should(profile).have.property('location', 'Florianópolis, Santa Catarina, Brazil');
should(profile).have.property('headline', 'Development Manager at Avalara');
should(profile).have.property('location', 'Florianópolis Area, Brazil');
should(profile).have.property('summary').be.ok();
should(profile).have.property('industry').be.equal('Program Development');
should(profile).have.property('languages').length(5);
should(profile).have.property('skills').length(45);
should(profile).have.property('currentPositions').length(3);
should(profile).have.property('pastPositions').length(3);
should(profile).have.property('skills').length(49);
should(profile).have.property('currentPositions').length(0);
should(profile).have.property('pastPositions').length(0);
should(profile).have.property('educations').length(1);
should(profile).have.property('positions').length(8);
should(profile).have.property('positions').length(10);
//should(profile).have.property('honors').length(0);
//should(profile).have.property('projects').length(0);
should(profile).have.property('projects').length(0);
should(profile).have.property('publicProfileUrl', url);
}

Expand Down