-
Notifications
You must be signed in to change notification settings - Fork 0
Searching for schools
Michał Oręziak edited this page Jun 12, 2019
·
4 revisions
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'))
})
- Search instance is created.
- 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 behighschool
,technicalSchool
orvocationalSchool
) -
test
- Does school require taking internal tests or exams? (Boolean) -
type
- Class type (Can bebilingual
,integration
,athletic
,integrationForDisabled
,generalAvailability
,international
,sportsMastery
) -
disabledFriendly
- Is school building disabled friendly? (Can betrue
,false
orpartly
) -
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
-
- Result is readable stream of objects with following properties
-
id
- Recruitment system school ID -
name
- School name
-
- Stream is being piped thru searchResultsToJSON function to create JSON array
- Data is being saved to
schools.json
file