Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ariya/penjabarberita
Extract the article list from its raw news HTML
https://github.com/ariya/penjabarberita
articles cheerio crawler headlines html indexer indonesia news scraper spider
Last synced: 15 days ago
JSON representation
Extract the article list from its raw news HTML
- Host: GitHub
- URL: https://github.com/ariya/penjabarberita
- Owner: ariya
- License: mit
- Created: 2020-05-17T12:01:26.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2022-11-24T14:30:41.000Z (almost 2 years ago)
- Last Synced: 2024-10-19T23:19:57.396Z (17 days ago)
- Topics: articles, cheerio, crawler, headlines, html, indexer, indonesia, news, scraper, spider
- Language: JavaScript
- Homepage: https://ariya.github.io/penjabarberita
- Size: 654 KB
- Stars: 16
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Penjabar Berita
[![npm (scoped)](https://img.shields.io/npm/v/@ariya/penjabarberita)](https://www.npmjs.com/package/@ariya/penjabarberita)
[![GitHub license](https://img.shields.io/github/license/ariya/penjabarberita)](https://github.com/ariya/penjabarberita/blob/master/LICENSE)
![Tests](https://github.com/ariya/penjabarberita/workflows/Tests/badge.svg)[Bahasa Indonesia](#indonesian) | [English](#english)
---
**Penjabar Berita**: Pustaka JavaScript untuk Node.js ([@ariya/penjabarberita](https://www.npmjs.com/package/@ariya/penjabarberita)) guna mendapatkan daftar artikel (judul, tautan, waktu) dari berkas HTML yang mewakili indeks berita tersebut.
Penjabar Berita dikhususkan untuk mengolah surat kabar daring Indonesia. Saat ini, yang bisa diproses adalah indeks berita dari Antara, BBC Indonesia, CNBC Indonesia, CNN Indonesia, Intisari, Jawa Pos, Kompas, Kontan, Liputan 6, Pikiran Rakyat, Republika, Suara, Tempo, The Conversations, TurnBackHoax, Viva News.
Instalasi: `npm install @ariya/penjabarberita`.
Misalkan berkas `data.html` didapatkan dengan mengambil indeks berita dari laman surat kabar Kompas, katakanlah menggunakan cURL dengan langkah `curl -o data.html https://www.kompas.com/tag/virus-corona`, maka berkas tersebut bisa diproses seperti di bawah ini:
```js
const fs = require('fs');
const penjabarberita = require('@ariya/penjabarberita');const buffer = fs.readFileSync('data.html', 'utf-8');
const list = penjabarberita(buffer.toString());
console.log(list.map(n => n.title));
```yang akan menghasilkan keluaran seperti:
```
[
'Pentingnya Meningkatkan Sistem Kekebalan Tubuh dengan Vitamin',
'Bisakah Virus Corona Bertahan di Rambut Manusia?',
// dst...
]
```Di samping judul artikel (`title`), bisa juga didapatkan tautan (`url`) dan tanggal/waktu (`timestamp`, sebagai Unix epoch).
---
**Penjabar Berita**: A JavaScript library for Node.js ([@ariya/penjabarberita](https://www.npmjs.com/package/@ariya/penjabarberita)) to extract the article list (title, link, timestamp) from its HTML representation.
Penjabar Berita is geared towards processing the article index of online news sites in Indonesia, currently supporting Antara, BBC Indonesia, CNBC Indonesia, CNN Indonesia, Intisari, Jawa Pos, Kompas, Kontan, Liputan 6, Pikiran Rakyat, Republika, Suara, Tempo, The Conversations, TurnBackHoax, Viva News.
Installation: `npm install @ariya/penjabarberita`.
Assuming `data.html` is obtained by retrieving the news index from Kompas, for instance (by using cURL) `curl -o data.html https://www.kompas.com/tag/virus-corona`, then the file can be processed as follows:
```js
const fs = require('fs');
const penjabarberita = require('@ariya/penjabarberita');const buffer = fs.readFileSync('data.html', 'utf-8');
const list = penjabarberita(buffer.toString());
console.log(list.map(n => n.title));
```which will result in:
```
[
'Pentingnya Meningkatkan Sistem Kekebalan Tubuh dengan Vitamin',
'Bisakah Virus Corona Bertahan di Rambut Manusia?',
// and so on...
]
```In addition to the article title (`title`), the article link (`url`) and published date/time (`timestamp`, as Unix epoch) are available as well.