Skip to content

Retrieve teletext pages from Finnish Broadcasting Company.

License

Notifications You must be signed in to change notification settings

RauliL/yle-teletext-scraper

Repository files navigation

Yle teletext scraper

Scrapes teletext pages from Finnish Broadcasting Company and returns their contents as plain text.

Can be used as a command line utility, Node.js library or in a browser.

Installation

$ npm install --save yle-teletext-scraper

Usage

Command line utility

If you install this package globally you can use command yle-teletext to retrieve pages and display them in your console.

$ yle-teletext [page = 100] [subpage = 1]

Library

The library exports a single function called get, which retrieves an teletext page, it's subpages (optionally) and so on. It's TypeScript type declaration looks like this:

get(
  page: number = 100,
  subpage: number = 1,
  fetchSubPages: boolean = true,
) => Promise<string[]>;

It returns an array of subpages which each containing text only version of the page contents. If the page does not exist, or some other network related error occurs, the promise will fail.

And this is how you can use it:

import { get } from 'yle-teletext-scraper';

get(100, 1)
  .then((pages) => {
    pages.forEach((page) => {
      console.log(page);
    });
  })
  .catch((error) => {
    console.error(error);
  });