Get Links via DOM / CSS Selector
Get Links via DOM / CSS Selector
Simple like: getLinks(url, selector)
npm install --save get-links
yarn add get-links
var getLinks = require('get-links')
import getLinks from 'get-links'
import getLinks from 'get-links'
import log from 'console-emoji'
// get pinned repository links from github
const url = 'https://github.com/ellerbrock'
const selector = '.pinned-repo-item-content .d-block a'
getLinks(url, selector)
.then(links => {
log('GitHub: Pinned Repositories:', 'ok')
links.forEach(v => log(` :link: ${url}${v}`))
})
Output should look like this:
Get the latest News about Web Development, Open Source, Tooling, Server & Security
Copyright (c) 2016 Maik Ellerbrock