aboutsummaryrefslogtreecommitdiff
path: root/src/getScheduleHtml.ts
diff options
context:
space:
mode:
authorwabilin <[email protected]>2020-07-31 20:15:19 +0900
committerwabilin <[email protected]>2020-07-31 20:15:19 +0900
commitdf2b1e4012dc50b56141bf9012d8e367a3d08fdf (patch)
treef1876fbd2ecceaeef2e6757818987c0474bca46e /src/getScheduleHtml.ts
parentadd jsdom (diff)
downloadholo-schedule-df2b1e4012dc50b56141bf9012d8e367a3d08fdf.tar.xz
holo-schedule-df2b1e4012dc50b56141bf9012d8e367a3d08fdf.zip
get datas without date
Diffstat (limited to 'src/getScheduleHtml.ts')
-rw-r--r--src/getScheduleHtml.ts37
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