Created
January 11, 2021 13:08
-
-
Save andriyor/ac42edb7ee4b871bc5ffa9284fceeed5 to your computer and use it in GitHub Desktop.
hl7-fhir-codes-table-parser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const puppeteer = require('puppeteer'); | |
const fs = require("fs"); | |
const path = require("path"); | |
(async () => { | |
const browser = await puppeteer.launch({headless: false}); | |
const page = await browser.newPage(); | |
await page.goto('https://www.hl7.org/fhir/valueset-allergyintolerance-code.html'); | |
const codes = await page.evaluate(() => { | |
const codes = [...document.querySelectorAll("table.codes tbody tr")].map((tr, index) => { | |
return { | |
values: [tr.querySelectorAll("td")[0].textContent.trim(), tr.querySelectorAll("td")[1].textContent, "", "{}"], | |
index | |
} | |
}) | |
codes.shift() | |
return codes; | |
}); | |
fs.writeFileSync(path.resolve(__dirname, 'result.json'), JSON.stringify(codes, null, 2)) | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment