File tree 1 file changed +41
-4
lines changed
1 file changed +41
-4
lines changed Original file line number Diff line number Diff line change @@ -97,10 +97,47 @@ pub async fn get_problem_async(problem_stat: StatWithStatus) -> Option<Problem>
97
97
}
98
98
99
99
pub fn get_problems ( ) -> Option < Problems > {
100
- reqwest:: blocking:: get ( PROBLEMS_URL )
101
- . unwrap ( )
102
- . json ( )
103
- . unwrap ( )
100
+ let headers = {
101
+ let mut h = reqwest:: header:: HeaderMap :: new ( ) ;
102
+ h. insert (
103
+ "User-Agent" ,
104
+ reqwest:: header:: HeaderValue :: from_static (
105
+ "Mozilla/5.0 (X11; Linux x86_64; rv:123.0) Gecko/20100101 Firefox/123.0" ,
106
+ ) ,
107
+ ) ;
108
+ h. insert (
109
+ "Referer" ,
110
+ reqwest:: header:: HeaderValue :: from_static ( PROBLEMS_URL ) ,
111
+ ) ;
112
+ h. insert (
113
+ "Origin" ,
114
+ reqwest:: header:: HeaderValue :: from_static ( PROBLEMS_URL ) ,
115
+ ) ;
116
+ h. insert (
117
+ "Content-Type" ,
118
+ reqwest:: header:: HeaderValue :: from_static ( "application/json" ) ,
119
+ ) ;
120
+ h. insert (
121
+ "Accept" ,
122
+ reqwest:: header:: HeaderValue :: from_static ( "application/json" ) ,
123
+ ) ;
124
+ h. insert (
125
+ "Host" ,
126
+ reqwest:: header:: HeaderValue :: from_static ( PROBLEMS_URL ) ,
127
+ ) ;
128
+ h. insert (
129
+ "X-Requested-With" ,
130
+ reqwest:: header:: HeaderValue :: from_static ( "XMLHttpRequest" ) ,
131
+ ) ;
132
+ h
133
+ } ;
134
+ let client = reqwest:: blocking:: Client :: builder ( )
135
+ . default_headers ( headers)
136
+ . build ( )
137
+ . unwrap ( ) ;
138
+ let res = client. get ( PROBLEMS_URL ) . send ( ) . unwrap ( ) . json ( ) ;
139
+ println ! ( "{:?}" , res) ;
140
+ res. unwrap ( )
104
141
}
105
142
106
143
#[ derive( Serialize , Deserialize ) ]
You can’t perform that action at this time.
0 commit comments