From e395de5f8c87cfc2dcbf4e6d142c605d3161c877 Mon Sep 17 00:00:00 2001 From: Magnus Deininger Date: Mon, 29 Sep 2014 11:30:27 +0400 Subject: [PATCH] start dealing with user pages --- bin/reave.js | 2 +- lib/reave.js | 16 +++++++++++++++- package.json | 2 +- 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/bin/reave.js b/bin/reave.js index 51fce4d..1cb53ac 100755 --- a/bin/reave.js +++ b/bin/reave.js @@ -2,4 +2,4 @@ var reave = require('../lib/reave.js'); -reave.medium(process.argv[2], console.log); +reave[process.argv[2]](process.argv[3], console.log); diff --git a/lib/reave.js b/lib/reave.js index b080b38..65e117a 100644 --- a/lib/reave.js +++ b/lib/reave.js @@ -94,6 +94,20 @@ function medium (URL, pageCallback) { }); } +function mediumUser (URL, pageCallback) { + fetch(https, URL, function(text) { + var out = cheerio.load(''+URL+''); + + var $ = cheerio.load(text); + var user = $('meta[property="profile:username"]').attr('content'); + + $('h3 a[href^="/@'+user+'"]').each(function(_, e) { + console.log($(this).attr('href')); + }); + }); +} + module.exports = { - 'medium': medium + 'medium': medium, + 'mediumUser': mediumUser }; diff --git a/package.json b/package.json index 9d8cd95..e54d94f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "reave", - "version": "0.1.3", + "version": "0.2.0", "description": "Scripts to fetch and simplify blog content.", "keywords": [ "cli",