Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

AtCoderで、指定した問題から高レートの人の解答を探して一覧を手に入れるためのやつです

NotificationsYou must be signed in to change notification settings

harukaeru/AtCoderCodeSearcher

Repository files navigation

Scrapyを使って、AtCoderのランキングに載っている上位のユーザーと、各問題でのユーザーの提出結果をクロールしてsqlite3に格納します。

格納されたデータはsqliteに保存されているので、以下のように好きに結合してデータを得ることができます。これはSQLPadというクライアントを使って接続している図です。

image

他人向けに作っていないので、使いにくいと思います。気が向いたらええ感じにサービスにします。

使い方

# ランキング情報をsqlite3に入れます(上位5100位まで)$python3python3fetch_ranking_to_db.py# 提出情報を格納します。ランキング情報に載っているユーザーしかデータベースには登録しません# 初期化とかは適当なので、適当にソースを読んでいい感じにしてください$python3fetch_submission_to_db.pyabc134_c$sqlite3atcoder.dbsqlite>select*fromatcoder_userLIMIT1;BY|tourist|ITMOUniversity|1|1994|3976

Philosophy

最初、スクレイピングするだけにとどめようとしたので、あとからsqliteを使うことにして、そのせいでなんかORMapperもどきを自作しています。

↓こういうの

classSubmission:@classmethoddefcreate_table(cls):return ['''        CREATE TABLE submission (          task_id, atcoder_user_name, code_size INT, execution_time INT, memory INT, link,          FOREIGN KEY (atcoder_user_name) REFERENCES atcoder_user(name)        )      ''','CREATE INDEX task_id_index ON submission(task_id)'    ]@classmethoddefdrop_table(cls):return'DROP TABLE submission'def__init__(self,task_id,atcoder_user_name,code_size,execution_time,memory,link):self.task_id=task_idself.atcoder_user_name=atcoder_user_nameself.code_size=code_sizeself.execution_time=execution_timeself.memory=memoryself.link=linkdef__repr__(self):returnf'<TaskID:{self.task_id}, ユーザ名:{self.atcoder_user_name}, Size:{self.code_size}KB, 実行時間:{self.execution_time}ms>'@instantiate('Submission')defcreate(self):returncreate_sql_statement("INSERT INTO submission VALUES ({}, {}, {}, {}, {}, {})",self.task_id,self.atcoder_user_name,self.code_size,self.execution_time,self.memory,self.link    )@classmethoddefdelete(cls,task_id):returnrun_sqls(f'DELETE FROM submission WHERE task_id = "{task_id}"')

Ref

Scrapyの使い方はここがわかりやすいです。

About

AtCoderで、指定した問題から高レートの人の解答を探して一覧を手に入れるためのやつです

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

[8]ページ先頭

©2009-2025 Movatter.jp