MCPcopy Create free account
hub / github.com/Tatamo/atcoder-cli / tasks

Method tasks

src/atcoder.ts:143–162  ·  view source on GitHub ↗

* 問題一覧を取得 * @param contest_id * @throws Error

(contest_id: string)

Source from the content-addressed store, hash-verified

141 * @throws Error
142 */
143 async tasks(contest_id: string): Promise<Array<Task>> {
144 // コンテストが見つからない場合エラーとなるがハンドルせず外に投げる
145 const response = await this.session.get(AtCoder.getTaskURL(contest_id));
146
147 const {JSDOM} = await import("jsdom");
148 const {document} = new JSDOM(response.data).window;
149 // very very ad-hoc and not type-safe section
150 const tbody = document.querySelector("#main-div .row table>tbody");
151 if (tbody === null) return [];
152 const tasks: Array<Task> = [];
153 for (const tr of tbody.querySelectorAll("tr")) {
154 // tr>td>a
155 const id: string = tr.children[0].children[0].getAttribute("href")!.split("/").pop()!;
156 const label: string = (tr.children[0].children[0] as HTMLAnchorElement).text;
157 const title: string = (tr.children[1].children[0] as HTMLAnchorElement).text;
158 const url: string = `${AtCoder.base_url}${tr.children[0].children[0].getAttribute("href")!.substring(1)}`;
159 tasks.push({id, label, title, url});
160 }
161 return tasks;
162 }
163
164 /**
165 * 単一の問題を取得

Callers 6

taskMethod · 0.95
tasksFunction · 0.80
urlFunction · 0.80
formatFunction · 0.80
initFunction · 0.80
atcoder.tsFile · 0.80

Calls 2

getTaskURLMethod · 0.80
getMethod · 0.65

Tested by

no test coverage detected