File tree Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Expand file tree Collapse file tree 1 file changed +14
-8
lines changed Original file line number Diff line number Diff line change @@ -3,15 +3,21 @@ use std::{error::Error, marker::Sync};
33
44#[ derive( Debug , Deserialize ) ]
55pub struct Problem {
6- pub id : String ,
7- pub contest_id : String ,
8- pub title : String ,
6+ pub id : String ,
7+ pub contest_id : String ,
8+ pub title : String ,
99}
1010
11- pub async fn fetch_problem ( ) -> Result < Vec < Problem > , Box < dyn Error +Send +Sync > > {
12- let url = "https://kenkoooo.com/atcoder/resources/problems.json" ;
13- let text = reqwest:: get ( url) . await ?. text ( ) . await ?;
14- let problem: Vec < Problem > = serde_json:: from_str ( & text) ?;
11+ pub async fn fetch_problem ( ) -> Result < Vec < Problem > , Box < dyn Error + Send + Sync > > {
12+ let url = "https://kenkoooo.com/atcoder/resources/problems.json" ;
1513
16- Ok ( problem)
14+ // reqwest::Clientを作成し、User-Agentヘッダーを追加
15+ let client = reqwest:: Client :: builder ( )
16+ . user_agent ( "atcoder-random-picker/0.1" ) // 任意の名前やバージョンを指定
17+ . build ( ) ?;
18+
19+ let text = client. get ( url) . send ( ) . await ?. text ( ) . await ?;
20+ let problem: Vec < Problem > = serde_json:: from_str ( & text) ?;
21+
22+ Ok ( problem)
1723}
You can’t perform that action at this time.
0 commit comments