Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mottox2/mini-scrape
simple scraping function
https://github.com/mottox2/mini-scrape
node npm
Last synced: 12 days ago
JSON representation
simple scraping function
- Host: GitHub
- URL: https://github.com/mottox2/mini-scrape
- Owner: mottox2
- Created: 2018-04-13T16:14:54.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2022-12-09T08:24:45.000Z (about 2 years ago)
- Last Synced: 2024-12-15T16:56:12.374Z (19 days ago)
- Topics: node, npm
- Language: JavaScript
- Homepage: https://www.npmjs.com/package/mini-scrape
- Size: 425 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 10
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# mini-scrape
[![npm version](https://badge.fury.io/js/mini-scrape.svg)](https://badge.fury.io/js/mini-scrape)
simple scrape function working on nodejs
## Installation
```
$ npm install mini-scrape
```or yarn
```
$ yarn install mini-scrape
```## Example
```js
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**
```js
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
```js
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, ''))
})
```