-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscraper.js
More file actions
40 lines (32 loc) · 896 Bytes
/
scraper.js
File metadata and controls
40 lines (32 loc) · 896 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import {
processGeneralData,
getNameValue,
getYearValue,
} from "./utils/scraper/processGeneralData.js"
import processTableData from "./utils/scraper/processTableData.js"
import insertSchoolData from "./model/school_data.js"
const scraper = async pdfPath => {
// SCHOOL NAME AND YEAR VALUES
const schoolname = { schoolname: getNameValue(pdfPath) }
const year = { year: getYearValue(pdfPath) }
// GENERAL VALUES
let pdfSchoolData = []
try {
pdfSchoolData = await processGeneralData(pdfPath)
} catch (error){
console.error(error)
}
// UDISE AND TABLE VALUES
let tableData
try {
tableData = await processTableData(pdfPath)
pdfSchoolData.push(tableData)
} catch (error){
console.log({tableData})
console.error(error)
}
pdfSchoolData.push(schoolname, year)
insertSchoolData(pdfSchoolData)
console.log(`Scraped`)
}
export default scraper