Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.37 KB | None | 0 0
  1. // Returns a list of emails for every page on the domains of the URL list
  2.  
  3. var EightyApp = function() {
  4. this.processDocument = function(html, url, headers, status, jQuery) {
  5. var app = this;
  6. $ = jQuery;
  7. var $html = app.parseHtml(html, $);
  8. var object = {};
  9.  
  10. // Get emails
  11. var emailList = [];
  12. emailList = html.match(/[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9]+)*(\.[a-z]{2,})/gi);
  13. object.emailList = emailList;
  14.  
  15. return JSON.stringify(object);
  16. }
  17.  
  18. this.parseLinks = function(html, url, headers, status, jQuery) {
  19. var app = this;
  20. var $ = jQuery;
  21. var $html = app.parseHtml(html, $);
  22. var links = [];
  23.  
  24. var r = /:\/\/(.[^/]+)/;
  25. var urlDomain = url.match(r)[1]
  26.  
  27. // gets all links in the html document
  28. $html.find('a').each(function(i, obj) {
  29. // console.log($(this).attr('href'));
  30. var link = app.makeLink(url, $(this).attr('href'));
  31.  
  32. if (link != null) {
  33. var linkDomain = link.match(r);
  34. if (linkDomain && linkDomain.length > 1) {
  35. linkDomain = linkDomain[1];
  36. if (urlDomain == linkDomain)
  37. links.push(link);
  38. }
  39. }
  40. });
  41.  
  42. return links;
  43. }
  44. }
  45.  
  46. try {
  47. // Testing
  48. module.exports = function(EightyAppBase) {
  49. EightyApp.prototype = new EightyAppBase();
  50. return new EightyApp();
  51. }
  52. } catch(e) {
  53. // Production
  54. console.log("Eighty app exists.");
  55. EightyApp.prototype = new EightyAppBase();
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement