npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

comcigan-parser-edited

v0.3.0

Published

Parse timetable data from comcigan.com

Downloads

5

Readme

comcigan-parser

📘🕘 컴시간 알리미 시간표 파싱 라이브러리 입니다.
본 라이브러리는 컴시간 홈페이지에서 등록된 학교의 시간표 데이터를 파싱하여 제공합니다.

기능

  • 학교명 입력 후 바로 사용 가능
  • 학급 시간표 데이터 제공

정보

해당 라이브러리는 컴시간 시간표 웹사이트(개발 중)를 위해 이근혁님의 comcigan-parser 를 수정하였습니다.

컴시간 서비스를 사용하는 학교의 시간표 데이터를 쉽게 수집하여 사용할 수 있습니다.

컴시간측의 소스코드 변경으로 인해 시간표 데이터 파싱이 불가능 할 수 있습니다. 문제가 발생할 경우 여기를 참고해주세요

(주의!) 본 라이브러리는 비공식적으로 컴시간 서비스의 데이터를 파싱하며, 상업적인 용도로 사용하다 문제가 발생할 경우 책임을 지지 않습니다.

설치하기

npm i comcigan-parser

개발 문서

Timetable

Timetable 클래스의 인스턴스를 생성하여 사용합니다.

const Timetable = require("comcigan-parser");
new Timetable();

(Method) Timetable.init

인스턴스 정보를 초기화 합니다.
옵션을 추가하여 사용자 설정을 진행할 수 있습니다.

| Parameter | Type | Required | | :-------- | :--: | :------: | | option | any | X |

옵션 정보는 아래 표 참고

| Option | Value | default | | :----------------- | :----: | :----------------------: | | firstNames | array | ['김', '박', '이', '송'] | | maxGrade | number | 3 | | timetableThreshold | number | 30000 |

  • firstNames - 교사 이름 추출 시 참고할 성씨 목록입니다.
  • maxGrade - 최대 학년을 지정합니다.
  • timetableThreshold - 시간표 데이터 임계값
    • 응답 데이터는 [0, 0, 0, 0, 0], [0, 10324, 52201, 8909, 0] 이와 같은 형식으로 수집되며 각 요소를 모두 더한 값이 지정한 임계값을 넘을 경우 해당 값을 시간표 데이터로 사용함
    • 비어있는 데이터 ([0, 0, 0, 0, 0])를 필터링하기 위해 사용

Return - Promise<any>

const timetable = new Timetable();
timetable.init(option);

(Method) Timetable.getTimetable

지정한 학교의 시간표 데이터를 불러옵니다.

Return - Promise<any>

timetable.getTimetable();

(Method) Timetable.getClassTime

각 교시별 수업 시작/종료 시간정보를 반환합니다.

Return - Array<string>

timetable.getClassTime();

추가된 기능

(Method) Timetable.searchSchool - 추가됨

입력된 키워드를 통해 학교를 조회하여 결과를 리턴합니다.

컴시간에 등록된 학교가 아닐 경우 검색되지 않습니다.

| Parameter | Type | Required | | :-------- | :----: | :------: | | keyword | string | O |

Return - Object

timetable.searchSchool(keyword);

사용 방법

Timetable 인스턴스 생성

comcigan-parser 모듈을 불러온 후 인스턴스를 생성합니다.
생성 후 반드시 init(option)를 호출하여 초기화 합니다.

const Timetable = require("comcigan-parser");
const timetable = new Timetable();

timetable.init(option).then(() => {
  // 초기화 완료..
});

학교 설정

컴시간에 등록되어있는 학교를 검색하고 인스턴스에 등록합니다.

학교가 여러개 조회되거나 검색 결과가 없는 경우 예외가 발생합니다.

timetable.setSchool("광명경영회계고등학교").then((result) => {
  console.log(result); //true
});

timetable.setSchool("테스트").then((result) => {
  console.log(result); //검색된 학교가 없습니다.
});

timetable.setSchool("우").then((result) => {
  console.log(result); //검색된 학교가 많습니다. 더 자세한 학교명을 입력해주세요. 검색 결과 수: ${searchData.length}
});

시간표 조회

등록한 학교의 시간표 데이터를 조회합니다.

timetable.getTimetable().then((result) => {
  console.log(result);

  // result[학년][반][요일][교시]
  // 요일: (월: 0 ~ 금: 4)
  // 교시: 1교시(0), 2교시(1), 3교시(2)..
  // 3학년 8반 화요일 2교시 시간표
  console.log(result[3][8][1][1]);
});

수업시간 정보 조회

timetable.getClassTime("광명경영회계고등학교").then((result) => {
  console.log(result); //광명경영회계고등학교
});

timetable.getClassTime("테스트").then((result) => {
  console.log(result); //검색된 학교가 없습니다.
});

timetable.getClassTime("우").then((result) => {
  console.log(result); //검색된 학교가 많습니다. 더 자세한 학교명을 입력해주세요. 검색 결과 수: ${searchData.length}
});

학교 조회

const time = timetable.searchSchool("");
console.log(time);

/*
[ '1(09:10)',
  '2(10:10)',
  '3(11:10)',
  '4(12:10)',
  '5(13:50)',
  '6(14:50)',
  '7(15:50)',
  '8(16:50)' ]
*/

사용 예제

const Timetable = require("comcigan-parser");
const timetable = new Timetable();

const test = async () => {
  await timetable.init();
  await timetable.setSchool("광명경영회계고등학교");

  // 전교 시간표 정보 조회
  const result = await timetable.getTimetable();
  console.log(result);

  // 각 교시별 수업 시작/종료 시간 정보 조회
  const time = timetable.getClassTime();
  console.log(time);
};

데이터 형식

시간표 데이터

{
  "1": {
    // 1학년
    "1": [ // 1반
      [ // 월요일 시간표
        {
          grade: 1,                   // 학년
          class: 1,                   // 반
          weekday: 1,                 // 요일 (1: 월 ~ 5: 금)
          weekdayString: '월',        // 요일 문자열
          class_time: 1,              // 교시
          code: '5644',               // 수업 코드
          teacher: '이희*',           // 선생님 성함
          subject: '실용비즈니스영어'  // 과목명
        },
        {
          grade: 1,
          class: 1,
          weekday: 1,
          weekdayString: '월',
          class_time: 2,
          code: '1606',
          teacher: '강연*',
          subject: '진로활동'
        }
      ],
      [화요일시간표],
      [수요일시간표],
      [목요일시간표],
      [금요일시간표]
    ],
    "2": [ // 2반
      [월요일시간표],
      [화요일시간표],
      [수요일시간표],
      [목요일시간표],
      [금요일시간표]
    ],
    "3": [
      [], [], [], [], []
    ],
    ...
  },
  "2": {
    // 2학년
  },
  "3": {
    // 3학년
  }
}
timetable.getTimetable().then((result) => {
  // 3학년 8반 시간표 (월 ~ 금)
  console.log(result[3][8]);

  // 1학년 1반 월요일 시간표
  console.log(result[1][1][0]);

  // 2학년 5반 금요일 3교시 시간표
  console.log(result[2][5][4][2]);
});

수업시간 정보

[
  "1(09:10)",
  "2(10:10)",
  "3(11:10)",
  "4(12:10)",
  "5(13:50)",
  "6(14:50)",
  "7(15:50)",
  "8(16:50)",
];

문제 신고

시간표 파싱이 되지 않거나 문제가 발생한 경우 이슈를 남겨주세요.

변경사항

  • 0.3.0
    • searchSchool 메소드 추가 ( 입력된 키워드를 통해 학교 조회 ) -참조

  • 0.2.0
    • getClassTime 메소드 추가 (각 교시별 수업 시작/종료 시간 정보) - 참조
  • 0.1.1
    • tempSave 옵션 문제 수정
  • 0.1.0
    • tempSave 옵션 삭제
    • 시간표 추출 데이터 임계값 옵션 추가 (자세한 사항은 여기 참조)
  • 0.0.3
    • 데이터 파싱 문제 수정
  • 0.0.2
    • 개발 문서 추가
    • init의 기본 옵션 문제 수정
  • 0.0.1 - 첫 번째 릴리즈!