diff options
Diffstat (limited to 'src/getScheduleHtml.ts')
| -rw-r--r-- | src/getScheduleHtml.ts | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/getScheduleHtml.ts b/src/getScheduleHtml.ts new file mode 100644 index 0000000..66df92e --- /dev/null +++ b/src/getScheduleHtml.ts @@ -0,0 +1,37 @@ +import https from 'https' + + +const OPTIONS = { + hostname: 'schedule.hololive.tv', + port: 443, + path: '/', + method: 'GET', + headers: { + Cookie: 'timezone=Asia/Tokyo' + } +} + +function getScheduleHtml(): Promise<string> { + const chunks: Uint8Array[] = []; + + return new Promise((resolve, reject) => { + const req = https.request(OPTIONS, res => { + res.on('data', chunk => { + chunks.push(chunk) + }) + + res.on('end', () => { + const html = Buffer.concat(chunks).toString('utf-8') + resolve(html) + }) + }) + + req.on('error', error => { + reject(error) + }) + + req.end() + }) +} + +export default getScheduleHtml |