Skip to content

Searching for schools

Michał Oręziak edited this page Jun 12, 2019 · 4 revisions

Searching for schools

const fs = require('fs')
const SearchConfig = require('@warsawlo/lava/utils/SearchConfig')
const searchResultsToJSON = require('@warsawlo/lava/utils/searchResultsToJSON')
const { 
    WARSAW_AFTER_SECONDARY_SCHOOL_URL
    } = require('@warsawlo/lava/urls/2019')

const Lava = require('./src/Lava')({
  baseURL: WARSAW_AFTER_SECONDARY_SCHOOL_URL
});

(async () => {
  const Search = new Lava.Search()
  const results = await Search.search(new SearchConfig({
    query: 'batorego',
    city: 'Warszawa'
  }))
  await Search.cleanUp()
  results
  .pipe(searchResultsToJSON)
  .pipe(fs.createWriteStream('./schools.json'))
})

Whats going on here?

  1. Search instance is created.
  2. search method on Search instance is called. You have to pass as argument SearchConfig instance with specified filters such as:
    • query - Search query for school name (String)
    • schoolType - School type (Can be highschool, technicalSchool or vocationalSchool)
    • test - Does school require taking internal tests or exams? (Boolean)
    • type - Class type (Can be bilingual, integration, athletic, integrationForDisabled, generalAvailability, international, sportsMastery)
    • disabledFriendly - Is school building disabled friendly? (Can be true, false or partly)
    • city - Which city school is located in? (WARNING! If you didn't select Warsaw recrutiment system omit this field). List of available cities:
      • Góra Kalwaria
      • Komornica
      • Konstancin-Jeziorna
      • Legionowo
      • Marki
      • Nasielsk
      • Nowy Dwór Mazowiecki
      • Piaseczno
      • Pomiechówek
      • Radzymin
      • Serock
      • Stanisławów Pierwszy
      • Sulejówek
      • Tarczyn
      • Tłuszcz
      • Urle
      • Warszawa
      • Wołomin
      • Zielonka
      • Żyrardów IMPORTANT!!! After getting results you have to call Search.cleanUp() in order to close running under the hood puppeteer browser
  3. Result is readable stream of objects with following properties
    • id - Recruitment system school ID
    • name - School name
  4. Stream is being piped thru searchResultsToJSON function to create JSON array
  5. Data is being saved to schools.json file
Clone this wiki locally