mottox2 / mini-scrape

simple scraping function

Home Page:https://www.npmjs.com/package/mini-scrape

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mini-scrape

npm version

simple scrape function working on nodejs

Installation

$ npm install mini-scrape

or yarn

$ yarn install mini-scrape

Example

const scrape = require('mini-scrape')
const url = 'https://github.com/mottox2/mini-scrape'

scrape(url).then(window => {
  console.log('title: ', window.document.title)
  console.log('h1: ', window.document.querySelector('h1').textContent.replace(/\n/g, ''))
})

webpack

import scrape from 'mini-scrape'
const url = 'https://github.com/mottox2/mini-scrape'

scrape(url).then(window => {
  console.log('title: ', window.document.title)
  console.log('h1: ', window.document.querySelector('h1').textContent.replace(/\n/g, ''))
})

with headers

import scrape from 'mini-scrape'
const url = 'https://github.com/mottox2/mini-scrape'

scrape(url, {
  headers: {
    'User-Agent': 'mini-scrape'
  }
}).then(window => {
  console.log('title: ', window.document.title)
  console.log('h1: ', window.document.querySelector('h1').textContent.replace(/\n/g, ''))
})

About

simple scraping function

https://www.npmjs.com/package/mini-scrape


Languages

Language:JavaScript 100.0%