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 🙏

© 2026 – Pkg Stats / Ryan Hefner

campus-square-scraper

v1.0.2

Published

Scraping library for CampusSquare university portal

Readme

Campus Square Scraper

npm version License: MIT

CampusSquare Scraper は、大学のポータルサイトシステム「CampusSquare」から成績情報やカレンダー情報を取得するための、Node.js用スクレイピングライブラリです。 セッション管理を自動化し、シンプルなAPIでデータにアクセスできます。

特徴

  • 🎓 成績取得: 全成績データをJSON形式で取得
  • 📅 カレンダー連携: 授業や試験スケジュールのICS(iCal)URLを取得
  • 🔐 セッション管理: ログインセッションの維持・再利用が容易
  • 🛡️ TypeScript: 型定義完備で安全な開発が可能
  • 🚀 軽量: 依存関係を最小限に抑え、Node.js標準の fetch を使用

インストール

npm install campus-square-scraper

使い方

1. 初期化

import { CampusSquareService } from 'campus-square-scraper';

const service = new CampusSquareService({
  baseUrl: 'https://csweb.u-aizu.ac.jp/campusweb', // 大学のCampusSquare URL
  // userAgent: 'MyBot/1.0', // 任意
});

2. ログインとデータ取得(推奨)

login メソッドで認証を行い、セッションオブジェクトを取得します。このセッションを使って各種データを取得します。

async function main() {
  try {
    // ログイン
    const session = await service.login('s1234567', 'password');
    console.log('Login success. SID:', session.sid);

    // 成績情報の取得
    const grades = await session.fetchGrades();
    console.log(`取得した成績: ${grades.length} 件`);
    grades.forEach(g => console.log(`${g.subject}: ${g.grade}`));

    // カレンダーURL(ICS)の取得
    const { calendarUrl } = await session.fetchCalendarUrl();
    console.log('Calendar ICS URL:', calendarUrl);
    
    // カレンダーイベントの取得
    const events = await session.fetchCalendarEvents(calendarUrl);
    console.log(`イベント数: ${events.length}`);

  } catch (error) {
    console.error('Error:', error);
  }
}

main();

3. 既存のセッションIDを利用する場合

既にブラウザや他の処理で取得した JSESSIONID がある場合、ログインをスキップして利用できます。

const session = service.fromSessionId('EXISTING_JSESSIONID_XYZ');
const grades = await session.fetchGrades();

4. ログインのみ(セッションID取得)

const { sid } = await service.login('user', 'pass');
console.log(sid); // 認証済みセッションID

設定オプション

CampusSquareService コンストラクタのオプション:

| オプション | 型 | 必須 | 説明 | | --- | --- | --- | --- | | baseUrl | string | ✅ | CampusSquareのベースURL (例: .../campusweb) | | userAgent | string | | リクエスト時に使用するUser-Agent | | debugNotify | function | | デバッグログを受け取るコールバック関数 |

要件

  • Node.js v18 以上 (標準 fetch APIを使用するため)

ライセンス

MIT