-
Notifications
You must be signed in to change notification settings - Fork 94
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
43 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,53 @@ | ||
/** | ||
* profile method scrapes a given GitHub user profile | ||
* @param {Object} $ - cheerio object with DOM of page to be scraped | ||
* @param {string} url - a valid GitHub issue url | ||
* @param {function} callback - the callback we should call after scraping | ||
* @param {String} url - a valid GitHub issue url | ||
* @param {Function} callback - the callback we should call after scraping | ||
* a callback passed into this method should accept two parameters: | ||
* @param {objectj} error an error object (set to null if no error occurred) | ||
* @param {object} data - the complete issue contents + meta data | ||
* @param {Object} error an error object (set to null if no error occurred) | ||
* @param {Object} data - the complete issue contents + meta data | ||
*/ | ||
module.exports = function issue($, url, callback) { | ||
/* UNCOMMENT THIS IF YOU HAVE TIME/PATIENTCE TO FIX IT...! | ||
|
||
var data = { entries : [], labels : [], participants : [] }; | ||
data.url = url; | ||
data.title = $('.js-issue-title').first().text().trim(); | ||
data.state = $('.state').first().text().trim(); | ||
console.log(' - - - - - > ' +data.state) | ||
// console.log($('.gh-header-title')); | ||
data.title = $('.gh-header-title').first().text().trim().split('\n')[0]; | ||
|
||
data.state = $('.State').first().text().trim(); | ||
data.author = $('.gh-header-meta .author').first().text().trim(); | ||
data.created = $('.gh-header-meta time')[0].attribs.datetime; | ||
data.created = $('relative-time')[0].attribs.datetime; | ||
|
||
// labels | ||
$('.label').each(function(){ | ||
$('.IssueLabel').each(function(){ | ||
data.labels.push($(this).attr('title')); | ||
}) | ||
// data.labels.filter((l) => l === true); | ||
var milestone = $('.milestone-name') | ||
if(milestone.length > 0){ | ||
data.milestone = milestone[0].attribs.title; | ||
} | ||
var assignee = $('.sidebar-assignee img'); | ||
var assignee = $('.assignee'); | ||
if(assignee.length > 0){ | ||
data.assignee = assignee[0].attribs.alt.replace('@', ''); | ||
data.assignee = assignee.text().trim(); | ||
} | ||
|
||
//participants | ||
$('.participant-avatar').each(function(){ | ||
data.participants.push($(this).attr('aria-label')); | ||
data.participants.push($(this).attr('href').replace('/','')); | ||
}) | ||
console.log(' - - - - - > data', data) | ||
// NOTE: this is possibly the most messed up DOM structure ever! | ||
// its almost as if someone @GitHub is deliberately trying ot prevent crawlers! | ||
// its almost as if someone @GitHub is deliberately trying to prevent crawlers | ||
var entries = $('.comment:nth-child(2)'); // yes! its bananas! | ||
for(var i=0; i < entries.length; i++) { | ||
var id = entries[i].attribs.id; // see: http://git.io/vOC5d | ||
var entry = {"id":id}; | ||
entry.author = $('#'+id+' .author').attr('href').replace('/',''); | ||
entry.created = $('#'+id+' time').attr('datetime'); | ||
entry.body = $('#'+id+' .comment-body').first().text().trim(); | ||
data.entries.push(entry); | ||
} | ||
// for(var i=0; i < entries.length; i++) { | ||
// var id = entries[i].attribs.id; // see: http://git.io/vOC5d | ||
// var entry = {"id":id}; | ||
// entry.author = $('#'+id+' .author').attr('href').replace('/',''); | ||
// entry.created = $('#'+id+' time').attr('datetime'); | ||
// entry.body = $('#'+id+' .comment-body').first().text().trim(); | ||
// data.entries.push(entry); | ||
// } | ||
return callback(null, data); | ||
*/ | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters