Skip to content

Instantly share code, notes, and snippets.

@sergii
Forked from devster31/example.html
Created February 12, 2021 21:13
Show Gist options
  • Select an option

  • Save sergii/416aee2eb1282480f749b9a7dba5975e to your computer and use it in GitHub Desktop.

Select an option

Save sergii/416aee2eb1282480f749b9a7dba5975e to your computer and use it in GitHub Desktop.

Revisions

  1. @devster31 devster31 revised this gist Jul 27, 2016. 1 changed file with 31 additions and 31 deletions.
    62 changes: 31 additions & 31 deletions output.json
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@
    "yosemite"
    ],
    "last_modified": null,
    "add_date": "1414706885"
    "add_date": "2014-10-30T22:08:05.000Z"
    },
    {
    "description": "\"Rails Assets is the frictionless proxy between Bundler and Bower. It automatically converts the packaged components into gems that are easily droppable into your asset pipeline and stay up to date.\"",
    @@ -39,7 +39,7 @@
    "development"
    ],
    "last_modified": null,
    "add_date": "1414632840"
    "add_date": "2014-10-30T01:34:00.000Z"
    },
    {
    "description": "",
    @@ -58,7 +58,7 @@
    "reference"
    ],
    "last_modified": null,
    "add_date": "1414511531"
    "add_date": "2014-10-28T15:52:11.000Z"
    },
    {
    "description": "",
    @@ -78,7 +78,7 @@
    "zachbraff"
    ],
    "last_modified": null,
    "add_date": "1413224537"
    "add_date": "2014-10-13T18:22:17.000Z"
    },
    {
    "description": "",
    @@ -98,7 +98,7 @@
    "tutorial"
    ],
    "last_modified": null,
    "add_date": "1412913363"
    "add_date": "2014-10-10T03:56:03.000Z"
    },
    {
    "description": "",
    @@ -119,7 +119,7 @@
    "concerns"
    ],
    "last_modified": null,
    "add_date": "1412871378"
    "add_date": "2014-10-09T16:16:18.000Z"
    },
    {
    "description": "",
    @@ -139,7 +139,7 @@
    "development"
    ],
    "last_modified": null,
    "add_date": "1412871345"
    "add_date": "2014-10-09T16:15:45.000Z"
    },
    {
    "description": "",
    @@ -161,7 +161,7 @@
    "development"
    ],
    "last_modified": null,
    "add_date": "1412870458"
    "add_date": "2014-10-09T16:00:58.000Z"
    },
    {
    "description": "",
    @@ -181,7 +181,7 @@
    "reference"
    ],
    "last_modified": null,
    "add_date": "1412348136"
    "add_date": "2014-10-03T14:55:36.000Z"
    },
    {
    "description": "Compatibility tables for default local fonts.",
    @@ -201,7 +201,7 @@
    "typography"
    ],
    "last_modified": null,
    "add_date": "1412085559"
    "add_date": "2014-09-30T13:59:19.000Z"
    },
    {
    "description": "Antibiotic prescribing guidelines for children in outpatient settings are to ensure appropriate treatment of common illnesses and improve patient outcomes.",
    @@ -216,14 +216,14 @@
    },
    {
    "name": "medicina",
    "last_modified": "1461089903",
    "add_date": "1461089902",
    "last_modified": "2016-04-19T18:18:23.000Z",
    "add_date": "2016-04-19T18:18:22.000Z",
    "level": 2
    }
    ],
    "tags": [],
    "last_modified": "1461089903",
    "add_date": "1461089902"
    "last_modified": "2016-04-19T18:18:23.000Z",
    "add_date": "2016-04-19T18:18:22.000Z"
    },
    {
    "description": "Antibiotic prescribing guidelines for adults in outpatient settings are used to ensure appropriate treatment of common illnesses and improve patient outcomes.",
    @@ -238,14 +238,14 @@
    },
    {
    "name": "medicina",
    "last_modified": "1461089903",
    "add_date": "1461089902",
    "last_modified": "2016-04-19T18:18:23.000Z",
    "add_date": "2016-04-19T18:18:22.000Z",
    "level": 2
    }
    ],
    "tags": [],
    "last_modified": "1461089903",
    "add_date": "1461089903"
    "last_modified": "2016-04-19T18:18:23.000Z",
    "add_date": "2016-04-19T18:18:23.000Z"
    },
    {
    "description": "",
    @@ -260,8 +260,8 @@
    },
    {
    "name": "medicina",
    "last_modified": "1461089903",
    "add_date": "1461089902",
    "last_modified": "2016-04-19T18:18:23.000Z",
    "add_date": "2016-04-19T18:18:22.000Z",
    "level": 2
    }
    ],
    @@ -271,7 +271,7 @@
    "reference"
    ],
    "last_modified": null,
    "add_date": "1412348136"
    "add_date": "2014-10-03T14:55:36.000Z"
    },
    {
    "description": "",
    @@ -286,14 +286,14 @@
    },
    {
    "name": "medicina",
    "last_modified": "1461089903",
    "add_date": "1461089902",
    "last_modified": "2016-04-19T18:18:23.000Z",
    "add_date": "2016-04-19T18:18:22.000Z",
    "level": 2
    },
    {
    "name": "medicina_nest",
    "last_modified": "1461089903",
    "add_date": "1461089902",
    "last_modified": "2016-04-19T18:18:23.000Z",
    "add_date": "2016-04-19T18:18:22.000Z",
    "level": 3
    }
    ],
    @@ -303,7 +303,7 @@
    "zachbraff"
    ],
    "last_modified": null,
    "add_date": "1413224537"
    "add_date": "2014-10-13T18:22:17.000Z"
    },
    {
    "description": "",
    @@ -318,14 +318,14 @@
    },
    {
    "name": "medicina",
    "last_modified": "1461089903",
    "add_date": "1461089902",
    "last_modified": "2016-04-19T18:18:23.000Z",
    "add_date": "2016-04-19T18:18:22.000Z",
    "level": 2
    },
    {
    "name": "medicina_nest",
    "last_modified": "1461089903",
    "add_date": "1461089902",
    "last_modified": "2016-04-19T18:18:23.000Z",
    "add_date": "2016-04-19T18:18:22.000Z",
    "level": 3
    }
    ],
    @@ -335,6 +335,6 @@
    "reference"
    ],
    "last_modified": null,
    "add_date": "1412348136"
    "add_date": "2014-10-03T14:55:36.000Z"
    }
    ]
  2. @devster31 devster31 revised this gist Jul 26, 2016. No changes.
  3. @devster31 devster31 revised this gist Jul 26, 2016. 4 changed files with 350 additions and 127 deletions.
    File renamed without changes.
    111 changes: 0 additions & 111 deletions output.js
    Original file line number Diff line number Diff line change
    @@ -1,111 +0,0 @@
    jsonbmArray =
    [ { description: 'This article describes JavaScript for Automation, a new feature in OS X Yosemite.',
    title: 'JavaScript for Automation Release Notes',
    url: 'https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/index.html#//apple_ref/doc/-%20uid/TP40014508',
    categories: [ [Object] ],
    tags: [ 'javascript', 'mac', 'osx', 'yosemite' ],
    last_modified: null,
    add_date: '1414706885' },
    { description: '"Rails Assets is the frictionless proxy between Bundler and Bower. It automatically converts the packaged components into gems that are easily droppable into your asset pipeline and stay up to date."',
    title: 'Rails Assets',
    url: 'https://rails-assets.org/',
    categories: [ [Object] ],
    tags: [ 'ruby', 'bundler', 'bower', 'development' ],
    last_modified: null,
    add_date: '1414632840' },
    { description: '',
    title: 'A Compendium of SVG Information | CSS-Tricks',
    url: 'http://css-tricks.com/mega-list-svg-information/',
    categories: [ [Object] ],
    tags: [ 'svg', 'reference' ],
    last_modified: null,
    add_date: '1414511531' },
    { description: '',
    title: 'Zach Braff Sold His Movie, Kickstarter Backers Await Rewards - NBC News.com',
    url: 'http://www.nbcnews.com/pop-culture/movies/zach-braff-sold-his-movie-kickstarter-backers-await-rewards-n14031',
    categories: [ [Object] ],
    tags: [ 'kickstarter', 'jasongarber', 'zachbraff' ],
    last_modified: null,
    add_date: '1413224537' },
    { description: '',
    title: 'Structuring Sinatra Applications',
    url: 'http://blog.sourcing.io/structuring-sinatra',
    categories: [ [Object] ],
    tags: [ 'ruby', 'sinatra', 'tutorial' ],
    last_modified: null,
    add_date: '1412913363' },
    { description: '',
    title: 'Rails Concerns II: Taggable',
    url: 'http://joshsymonds.com/blog/2012/07/04/rails-concerns-ii-taggable/',
    categories: [ [Object] ],
    tags: [ 'ruby', 'development', 'activerecord', 'concerns' ],
    last_modified: null,
    add_date: '1412871378' },
    { description: '',
    title: 'Put chubby models on a diet with concerns',
    url: 'https://signalvnoise.com/posts/3372-put-chubby-models-on-a-diet-with-concerns',
    categories: [ [Object] ],
    tags: [ 'ruby', 'activerecord', 'development' ],
    last_modified: null,
    add_date: '1412871345' },
    { description: '',
    title: 'Polymorphic many-to-many associations in Rails',
    url: 'http://www.brentmc79.com/posts/polymorphic-many-to-many-associations-in-rails',
    categories: [ [Object] ],
    tags:
    [ 'ruby',
    'polymorphism',
    'activerecord',
    'tutorial',
    'development' ],
    last_modified: null,
    add_date: '1412870458' },
    { description: '',
    title: 'You Might Not Need jQuery',
    url: 'http://youmightnotneedjquery.com/#parse_html',
    categories: [ [Object] ],
    tags: [ 'javascript', 'development', 'reference' ],
    last_modified: null,
    add_date: '1412348136' },
    { description: 'Compatibility tables for default local fonts.',
    title: 'fontfamily.io',
    url: 'http://fontfamily.io/',
    categories: [ [Object] ],
    tags: [ '@font-face', 'os', 'typography' ],
    last_modified: null,
    add_date: '1412085559' },
    { description: 'Antibiotic prescribing guidelines for children in outpatient settings are to ensure appropriate treatment of common illnesses and improve patient outcomes.',
    title: 'Get Smart About Antibiotics | Pediatric Treatment Recommendations | CDC',
    url: 'http://www.cdc.gov/getsmart/community/for-hcp/outpatient-hcp/pediatric-treatment-rec.html',
    categories: [ [Object], [Object] ],
    tags: [],
    last_modified: '1461089903',
    add_date: '1461089902' },
    { description: 'Antibiotic prescribing guidelines for adults in outpatient settings are used to ensure appropriate treatment of common illnesses and improve patient outcomes.',
    title: 'Get Smart About Antibiotics | Adult Treatment Recommendations | CDC',
    url: 'http://www.cdc.gov/getsmart/community/for-hcp/outpatient-hcp/adult-treatment-rec.html',
    categories: [ [Object], [Object] ],
    tags: [],
    last_modified: '1461089903',
    add_date: '1461089903' },
    { description: '',
    title: 'You Might Not Need jQuery',
    url: 'http://youmightnotneedjquery.com/#parse_html',
    categories: [ [Object], [Object] ],
    tags: [ 'javascript', 'development', 'reference' ],
    last_modified: null,
    add_date: '1412348136' },
    { description: '',
    title: 'Zach Braff Sold His Movie, Kickstarter Backers Await Rewards - NBC News.com',
    url: 'http://www.nbcnews.com/pop-culture/movies/zach-braff-sold-his-movie-kickstarter-backers-await-rewards-n14031',
    categories: [ [Object], [Object], [Object] ],
    tags: [ 'kickstarter', 'jasongarber', 'zachbraff' ],
    last_modified: null,
    add_date: '1413224537' },
    { description: '',
    title: 'You Might Not Need jQuery',
    url: 'http://youmightnotneedjquery.com/#parse_html',
    categories: [ [Object], [Object], [Object] ],
    tags: [ 'javascript', 'development', 'reference' ],
    last_modified: null,
    add_date: '1412348136' } ]
    340 changes: 340 additions & 0 deletions output.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,340 @@
    [
    {
    "description": "This article describes JavaScript for Automation, a new feature in OS X Yosemite.",
    "title": "JavaScript for Automation Release Notes",
    "url": "https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/index.html#//apple_ref/doc/-%20uid/TP40014508",
    "categories": [
    {
    "name": "Bookmarks",
    "last_modified": null,
    "add_date": null,
    "level": 1
    }
    ],
    "tags": [
    "javascript",
    "mac",
    "osx",
    "yosemite"
    ],
    "last_modified": null,
    "add_date": "1414706885"
    },
    {
    "description": "\"Rails Assets is the frictionless proxy between Bundler and Bower. It automatically converts the packaged components into gems that are easily droppable into your asset pipeline and stay up to date.\"",
    "title": "Rails Assets",
    "url": "https://rails-assets.org/",
    "categories": [
    {
    "name": "Bookmarks",
    "last_modified": null,
    "add_date": null,
    "level": 1
    }
    ],
    "tags": [
    "ruby",
    "bundler",
    "bower",
    "development"
    ],
    "last_modified": null,
    "add_date": "1414632840"
    },
    {
    "description": "",
    "title": "A Compendium of SVG Information | CSS-Tricks",
    "url": "http://css-tricks.com/mega-list-svg-information/",
    "categories": [
    {
    "name": "Bookmarks",
    "last_modified": null,
    "add_date": null,
    "level": 1
    }
    ],
    "tags": [
    "svg",
    "reference"
    ],
    "last_modified": null,
    "add_date": "1414511531"
    },
    {
    "description": "",
    "title": "Zach Braff Sold His Movie, Kickstarter Backers Await Rewards - NBC News.com",
    "url": "http://www.nbcnews.com/pop-culture/movies/zach-braff-sold-his-movie-kickstarter-backers-await-rewards-n14031",
    "categories": [
    {
    "name": "Bookmarks",
    "last_modified": null,
    "add_date": null,
    "level": 1
    }
    ],
    "tags": [
    "kickstarter",
    "jasongarber",
    "zachbraff"
    ],
    "last_modified": null,
    "add_date": "1413224537"
    },
    {
    "description": "",
    "title": "Structuring Sinatra Applications",
    "url": "http://blog.sourcing.io/structuring-sinatra",
    "categories": [
    {
    "name": "Bookmarks",
    "last_modified": null,
    "add_date": null,
    "level": 1
    }
    ],
    "tags": [
    "ruby",
    "sinatra",
    "tutorial"
    ],
    "last_modified": null,
    "add_date": "1412913363"
    },
    {
    "description": "",
    "title": "Rails Concerns II: Taggable",
    "url": "http://joshsymonds.com/blog/2012/07/04/rails-concerns-ii-taggable/",
    "categories": [
    {
    "name": "Bookmarks",
    "last_modified": null,
    "add_date": null,
    "level": 1
    }
    ],
    "tags": [
    "ruby",
    "development",
    "activerecord",
    "concerns"
    ],
    "last_modified": null,
    "add_date": "1412871378"
    },
    {
    "description": "",
    "title": "Put chubby models on a diet with concerns",
    "url": "https://signalvnoise.com/posts/3372-put-chubby-models-on-a-diet-with-concerns",
    "categories": [
    {
    "name": "Bookmarks",
    "last_modified": null,
    "add_date": null,
    "level": 1
    }
    ],
    "tags": [
    "ruby",
    "activerecord",
    "development"
    ],
    "last_modified": null,
    "add_date": "1412871345"
    },
    {
    "description": "",
    "title": "Polymorphic many-to-many associations in Rails",
    "url": "http://www.brentmc79.com/posts/polymorphic-many-to-many-associations-in-rails",
    "categories": [
    {
    "name": "Bookmarks",
    "last_modified": null,
    "add_date": null,
    "level": 1
    }
    ],
    "tags": [
    "ruby",
    "polymorphism",
    "activerecord",
    "tutorial",
    "development"
    ],
    "last_modified": null,
    "add_date": "1412870458"
    },
    {
    "description": "",
    "title": "You Might Not Need jQuery",
    "url": "http://youmightnotneedjquery.com/#parse_html",
    "categories": [
    {
    "name": "Bookmarks",
    "last_modified": null,
    "add_date": null,
    "level": 1
    }
    ],
    "tags": [
    "javascript",
    "development",
    "reference"
    ],
    "last_modified": null,
    "add_date": "1412348136"
    },
    {
    "description": "Compatibility tables for default local fonts.",
    "title": "fontfamily.io",
    "url": "http://fontfamily.io/",
    "categories": [
    {
    "name": "Bookmarks",
    "last_modified": null,
    "add_date": null,
    "level": 1
    }
    ],
    "tags": [
    "@font-face",
    "os",
    "typography"
    ],
    "last_modified": null,
    "add_date": "1412085559"
    },
    {
    "description": "Antibiotic prescribing guidelines for children in outpatient settings are to ensure appropriate treatment of common illnesses and improve patient outcomes.",
    "title": "Get Smart About Antibiotics | Pediatric Treatment Recommendations | CDC",
    "url": "http://www.cdc.gov/getsmart/community/for-hcp/outpatient-hcp/pediatric-treatment-rec.html",
    "categories": [
    {
    "name": "Bookmarks",
    "last_modified": null,
    "add_date": null,
    "level": 1
    },
    {
    "name": "medicina",
    "last_modified": "1461089903",
    "add_date": "1461089902",
    "level": 2
    }
    ],
    "tags": [],
    "last_modified": "1461089903",
    "add_date": "1461089902"
    },
    {
    "description": "Antibiotic prescribing guidelines for adults in outpatient settings are used to ensure appropriate treatment of common illnesses and improve patient outcomes.",
    "title": "Get Smart About Antibiotics | Adult Treatment Recommendations | CDC",
    "url": "http://www.cdc.gov/getsmart/community/for-hcp/outpatient-hcp/adult-treatment-rec.html",
    "categories": [
    {
    "name": "Bookmarks",
    "last_modified": null,
    "add_date": null,
    "level": 1
    },
    {
    "name": "medicina",
    "last_modified": "1461089903",
    "add_date": "1461089902",
    "level": 2
    }
    ],
    "tags": [],
    "last_modified": "1461089903",
    "add_date": "1461089903"
    },
    {
    "description": "",
    "title": "You Might Not Need jQuery",
    "url": "http://youmightnotneedjquery.com/#parse_html",
    "categories": [
    {
    "name": "Bookmarks",
    "last_modified": null,
    "add_date": null,
    "level": 1
    },
    {
    "name": "medicina",
    "last_modified": "1461089903",
    "add_date": "1461089902",
    "level": 2
    }
    ],
    "tags": [
    "javascript",
    "development",
    "reference"
    ],
    "last_modified": null,
    "add_date": "1412348136"
    },
    {
    "description": "",
    "title": "Zach Braff Sold His Movie, Kickstarter Backers Await Rewards - NBC News.com",
    "url": "http://www.nbcnews.com/pop-culture/movies/zach-braff-sold-his-movie-kickstarter-backers-await-rewards-n14031",
    "categories": [
    {
    "name": "Bookmarks",
    "last_modified": null,
    "add_date": null,
    "level": 1
    },
    {
    "name": "medicina",
    "last_modified": "1461089903",
    "add_date": "1461089902",
    "level": 2
    },
    {
    "name": "medicina_nest",
    "last_modified": "1461089903",
    "add_date": "1461089902",
    "level": 3
    }
    ],
    "tags": [
    "kickstarter",
    "jasongarber",
    "zachbraff"
    ],
    "last_modified": null,
    "add_date": "1413224537"
    },
    {
    "description": "",
    "title": "You Might Not Need jQuery",
    "url": "http://youmightnotneedjquery.com/#parse_html",
    "categories": [
    {
    "name": "Bookmarks",
    "last_modified": null,
    "add_date": null,
    "level": 1
    },
    {
    "name": "medicina",
    "last_modified": "1461089903",
    "add_date": "1461089902",
    "level": 2
    },
    {
    "name": "medicina_nest",
    "last_modified": "1461089903",
    "add_date": "1461089902",
    "level": 3
    }
    ],
    "tags": [
    "javascript",
    "development",
    "reference"
    ],
    "last_modified": null,
    "add_date": "1412348136"
    }
    ]
    26 changes: 10 additions & 16 deletions parser.js
    Original file line number Diff line number Diff line change
    @@ -1,14 +1,12 @@
    let fs = require('fs')
    let cheerio = require('cheerio')
    var cli = process.argv.slice(2)
    var path = require('path')
    var fs = require('fs')
    var cheerio = require('cheerio')

    let $ = cheerio.load(fs.readFileSync(<argv 1>))

    function attribsOnly(value) {
    return value['attribs'];
    }
    var $ = cheerio.load(fs.readFileSync(path.resolve(__dirname, cli[0])))

    function getCategories($a) {
    var $node = $a.closest("DL").prev();
    var $node = $a.closest('DL').prev();
    var title = $node.text();
    var add_date = $node.attr("add_date");
    var last_modified = $node.attr("last_modified");
    @@ -23,24 +21,22 @@ function getCategories($a) {
    }
    }

    let links = $('a').toArray().map(attribsOnly)
    let jsonbmArray = []
    var jsonbmArray = []
    $('a').each(function(index, a) {
    let $a = $(a)
    let add_date = $a.attr('add_date')
    let last_modified = $a.attr('last_modified')
    let description = $a.next('dd').text().split("\n")[0] // ugly but works
    let categories = getCategories($a)
    // add level information
    categories.reverse().map(function(currentValue, index) {
    return currentValue['level'] = index + 1 // return value problem
    let new_categories = categories.reverse().map(function(currentValue, index) {
    return currentValue['level'] = index + 1, currentValue
    })
    try {
    var tags = $a.attr('tags').split(',') || []
    } catch(e) {
    var tags = []
    }
    // let jsonbm = JSON.stringify({
    let jsonbm = {
    'description': description,
    'title': $a.text(),
    @@ -50,9 +46,7 @@ $('a').each(function(index, a) {
    'last_modified': typeof last_modified === "undefined" ? null : last_modified ,
    'add_date': typeof add_date === "undefined" ? null : add_date,
    }
    // }, null, 4)
    console.log(jsonbm);
    jsonbmArray.push(jsonbm)
    })

    fs.writeFileSync(<argv 2>, JSON.stringify(jsonbmArray, null, 4))
    fs.writeFileSync(path.resolve(__dirname, cli[1]), JSON.stringify(jsonbmArray, null, 4))
  4. @devster31 devster31 revised this gist Jul 26, 2016. 1 changed file with 111 additions and 0 deletions.
    111 changes: 111 additions & 0 deletions output.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,111 @@
    jsonbmArray =
    [ { description: 'This article describes JavaScript for Automation, a new feature in OS X Yosemite.',
    title: 'JavaScript for Automation Release Notes',
    url: 'https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/index.html#//apple_ref/doc/-%20uid/TP40014508',
    categories: [ [Object] ],
    tags: [ 'javascript', 'mac', 'osx', 'yosemite' ],
    last_modified: null,
    add_date: '1414706885' },
    { description: '"Rails Assets is the frictionless proxy between Bundler and Bower. It automatically converts the packaged components into gems that are easily droppable into your asset pipeline and stay up to date."',
    title: 'Rails Assets',
    url: 'https://rails-assets.org/',
    categories: [ [Object] ],
    tags: [ 'ruby', 'bundler', 'bower', 'development' ],
    last_modified: null,
    add_date: '1414632840' },
    { description: '',
    title: 'A Compendium of SVG Information | CSS-Tricks',
    url: 'http://css-tricks.com/mega-list-svg-information/',
    categories: [ [Object] ],
    tags: [ 'svg', 'reference' ],
    last_modified: null,
    add_date: '1414511531' },
    { description: '',
    title: 'Zach Braff Sold His Movie, Kickstarter Backers Await Rewards - NBC News.com',
    url: 'http://www.nbcnews.com/pop-culture/movies/zach-braff-sold-his-movie-kickstarter-backers-await-rewards-n14031',
    categories: [ [Object] ],
    tags: [ 'kickstarter', 'jasongarber', 'zachbraff' ],
    last_modified: null,
    add_date: '1413224537' },
    { description: '',
    title: 'Structuring Sinatra Applications',
    url: 'http://blog.sourcing.io/structuring-sinatra',
    categories: [ [Object] ],
    tags: [ 'ruby', 'sinatra', 'tutorial' ],
    last_modified: null,
    add_date: '1412913363' },
    { description: '',
    title: 'Rails Concerns II: Taggable',
    url: 'http://joshsymonds.com/blog/2012/07/04/rails-concerns-ii-taggable/',
    categories: [ [Object] ],
    tags: [ 'ruby', 'development', 'activerecord', 'concerns' ],
    last_modified: null,
    add_date: '1412871378' },
    { description: '',
    title: 'Put chubby models on a diet with concerns',
    url: 'https://signalvnoise.com/posts/3372-put-chubby-models-on-a-diet-with-concerns',
    categories: [ [Object] ],
    tags: [ 'ruby', 'activerecord', 'development' ],
    last_modified: null,
    add_date: '1412871345' },
    { description: '',
    title: 'Polymorphic many-to-many associations in Rails',
    url: 'http://www.brentmc79.com/posts/polymorphic-many-to-many-associations-in-rails',
    categories: [ [Object] ],
    tags:
    [ 'ruby',
    'polymorphism',
    'activerecord',
    'tutorial',
    'development' ],
    last_modified: null,
    add_date: '1412870458' },
    { description: '',
    title: 'You Might Not Need jQuery',
    url: 'http://youmightnotneedjquery.com/#parse_html',
    categories: [ [Object] ],
    tags: [ 'javascript', 'development', 'reference' ],
    last_modified: null,
    add_date: '1412348136' },
    { description: 'Compatibility tables for default local fonts.',
    title: 'fontfamily.io',
    url: 'http://fontfamily.io/',
    categories: [ [Object] ],
    tags: [ '@font-face', 'os', 'typography' ],
    last_modified: null,
    add_date: '1412085559' },
    { description: 'Antibiotic prescribing guidelines for children in outpatient settings are to ensure appropriate treatment of common illnesses and improve patient outcomes.',
    title: 'Get Smart About Antibiotics | Pediatric Treatment Recommendations | CDC',
    url: 'http://www.cdc.gov/getsmart/community/for-hcp/outpatient-hcp/pediatric-treatment-rec.html',
    categories: [ [Object], [Object] ],
    tags: [],
    last_modified: '1461089903',
    add_date: '1461089902' },
    { description: 'Antibiotic prescribing guidelines for adults in outpatient settings are used to ensure appropriate treatment of common illnesses and improve patient outcomes.',
    title: 'Get Smart About Antibiotics | Adult Treatment Recommendations | CDC',
    url: 'http://www.cdc.gov/getsmart/community/for-hcp/outpatient-hcp/adult-treatment-rec.html',
    categories: [ [Object], [Object] ],
    tags: [],
    last_modified: '1461089903',
    add_date: '1461089903' },
    { description: '',
    title: 'You Might Not Need jQuery',
    url: 'http://youmightnotneedjquery.com/#parse_html',
    categories: [ [Object], [Object] ],
    tags: [ 'javascript', 'development', 'reference' ],
    last_modified: null,
    add_date: '1412348136' },
    { description: '',
    title: 'Zach Braff Sold His Movie, Kickstarter Backers Await Rewards - NBC News.com',
    url: 'http://www.nbcnews.com/pop-culture/movies/zach-braff-sold-his-movie-kickstarter-backers-await-rewards-n14031',
    categories: [ [Object], [Object], [Object] ],
    tags: [ 'kickstarter', 'jasongarber', 'zachbraff' ],
    last_modified: null,
    add_date: '1413224537' },
    { description: '',
    title: 'You Might Not Need jQuery',
    url: 'http://youmightnotneedjquery.com/#parse_html',
    categories: [ [Object], [Object], [Object] ],
    tags: [ 'javascript', 'development', 'reference' ],
    last_modified: null,
    add_date: '1412348136' } ]
  5. @devster31 devster31 created this gist Jul 26, 2016.
    35 changes: 35 additions & 0 deletions delicious.html
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    <!DOCTYPE NETSCAPE-Bookmark-file-1>
    <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
    <!-- This is an automatically generated file.
    It will be read and overwritten.
    Do Not Edit! -->
    <TITLE>Bookmarks</TITLE>
    <H1>Bookmarks</H1>
    <DL><p>
    <DT><A HREF="https://developer.apple.com/library/mac/releasenotes/InterapplicationCommunication/RN-JavaScriptForAutomation/index.html#//apple_ref/doc/-%20uid/TP40014508" ADD_DATE="1414706885" PRIVATE="0" TAGS="javascript,mac,osx,yosemite">JavaScript for Automation Release Notes</A>
    <DD>This article describes JavaScript for Automation, a new feature in OS X Yosemite.
    <DT><A HREF="https://rails-assets.org/" ADD_DATE="1414632840" PRIVATE="0" TAGS="ruby,bundler,bower,development">Rails Assets</A>
    <DD>"Rails Assets is the frictionless proxy between Bundler and Bower. It automatically converts the packaged components into gems that are easily droppable into your asset pipeline and stay up to date."
    <DT><A HREF="http://css-tricks.com/mega-list-svg-information/" ADD_DATE="1414511531" PRIVATE="0" TAGS="svg,reference">A Compendium of SVG Information | CSS-Tricks</A>
    <DT><A HREF="http://www.nbcnews.com/pop-culture/movies/zach-braff-sold-his-movie-kickstarter-backers-await-rewards-n14031" ADD_DATE="1413224537" PRIVATE="0" TAGS="kickstarter,jasongarber,zachbraff">Zach Braff Sold His Movie, Kickstarter Backers Await Rewards - NBC News.com</A>
    <DT><A HREF="http://blog.sourcing.io/structuring-sinatra" ADD_DATE="1412913363" PRIVATE="0" TAGS="ruby,sinatra,tutorial">Structuring Sinatra Applications</A>
    <DT><A HREF="http://joshsymonds.com/blog/2012/07/04/rails-concerns-ii-taggable/" ADD_DATE="1412871378" PRIVATE="0" TAGS="ruby,development,activerecord,concerns">Rails Concerns II: Taggable</A>
    <DT><A HREF="https://signalvnoise.com/posts/3372-put-chubby-models-on-a-diet-with-concerns" ADD_DATE="1412871345" PRIVATE="0" TAGS="ruby,activerecord,development">Put chubby models on a diet with concerns</A>
    <DT><A HREF="http://www.brentmc79.com/posts/polymorphic-many-to-many-associations-in-rails" ADD_DATE="1412870458" PRIVATE="0" TAGS="ruby,polymorphism,activerecord,tutorial,development">Polymorphic many-to-many associations in Rails</A>
    <DT><A HREF="http://youmightnotneedjquery.com/#parse_html" ADD_DATE="1412348136" PRIVATE="0" TAGS="javascript,development,reference">You Might Not Need jQuery</A>
    <DT><A HREF="http://fontfamily.io/" ADD_DATE="1412085559" PRIVATE="0" TAGS="@font-face,os,typography">fontfamily.io</A>
    <DD>Compatibility tables for default local fonts.
    <DT><H3 ADD_DATE="1461089902" LAST_MODIFIED="1461089903">medicina</H3>
    <DL><p>
    <DT><A HREF="http://www.cdc.gov/getsmart/community/for-hcp/outpatient-hcp/pediatric-treatment-rec.html" ADD_DATE="1461089902" LAST_MODIFIED="1461089903">Get Smart About Antibiotics | Pediatric Treatment Recommendations | CDC</A>
    <DD>Antibiotic prescribing guidelines for children in outpatient settings are to ensure appropriate treatment of common illnesses and improve patient outcomes.
    <DT><A HREF="http://www.cdc.gov/getsmart/community/for-hcp/outpatient-hcp/adult-treatment-rec.html" ADD_DATE="1461089903" LAST_MODIFIED="1461089903">Get Smart About Antibiotics | Adult Treatment Recommendations | CDC</A>
    <DD>Antibiotic prescribing guidelines for adults in outpatient settings are used to ensure appropriate treatment of common illnesses and improve patient outcomes.
    <DT><A HREF="http://youmightnotneedjquery.com/#parse_html" ADD_DATE="1412348136" PRIVATE="0" TAGS="javascript,development,reference">You Might Not Need jQuery</A>
    <DT><H3 ADD_DATE="1461089902" LAST_MODIFIED="1461089903">medicina_nest</H3>
    <DL><p>
    <DT><A HREF="http://www.nbcnews.com/pop-culture/movies/zach-braff-sold-his-movie-kickstarter-backers-await-rewards-n14031" ADD_DATE="1413224537" PRIVATE="0" TAGS="kickstarter,jasongarber,zachbraff">Zach Braff Sold His Movie, Kickstarter Backers Await Rewards - NBC News.com</A>
    <DT><A HREF="http://youmightnotneedjquery.com/#parse_html" ADD_DATE="1412348136" PRIVATE="0" TAGS="javascript,development,reference">You Might Not Need jQuery</A>
    </DL><p>
    </DL><p>
    </DL><p>
    58 changes: 58 additions & 0 deletions parser.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,58 @@
    let fs = require('fs')
    let cheerio = require('cheerio')

    let $ = cheerio.load(fs.readFileSync(<argv 1>))

    function attribsOnly(value) {
    return value['attribs'];
    }

    function getCategories($a) {
    var $node = $a.closest("DL").prev();
    var title = $node.text();
    var add_date = $node.attr("add_date");
    var last_modified = $node.attr("last_modified");
    if ($node.length > 0 && title.length > 0) {
    return [{
    'name': title,
    'last_modified': typeof last_modified === "undefined" ? null : last_modified ,
    'add_date': typeof add_date === "undefined" ? null : add_date,
    }].concat(getCategories($node));
    } else {
    return [];
    }
    }

    let links = $('a').toArray().map(attribsOnly)
    let jsonbmArray = []
    $('a').each(function(index, a) {
    let $a = $(a)
    let add_date = $a.attr('add_date')
    let last_modified = $a.attr('last_modified')
    let description = $a.next('dd').text().split("\n")[0] // ugly but works
    let categories = getCategories($a)
    // add level information
    categories.reverse().map(function(currentValue, index) {
    return currentValue['level'] = index + 1 // return value problem
    })
    try {
    var tags = $a.attr('tags').split(',') || []
    } catch(e) {
    var tags = []
    }
    // let jsonbm = JSON.stringify({
    let jsonbm = {
    'description': description,
    'title': $a.text(),
    'url': $a.attr('href'),
    'categories': categories,
    'tags': tags,
    'last_modified': typeof last_modified === "undefined" ? null : last_modified ,
    'add_date': typeof add_date === "undefined" ? null : add_date,
    }
    // }, null, 4)
    console.log(jsonbm);
    jsonbmArray.push(jsonbm)
    })

    fs.writeFileSync(<argv 2>, JSON.stringify(jsonbmArray, null, 4))