@@ -77,6 +77,7 @@ def _request(self, method: str, path: str, body: Optional[dict] = None) -> dict:
7777 headers = {
7878 "x-api-key" : self ._api_key ,
7979 "Content-Type" : "application/json" ,
80+ "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" ,
8081 },
8182 )
8283 try :
@@ -111,7 +112,7 @@ def bypass(self, url: str, *, refresh: bool = False) -> BypassResult:
111112 raise BypassToolsError ("url is required" , "MISSING_URL" )
112113 data = self ._request ("POST" , "/bypass/direct" , {"url" : url , "refresh" : refresh })
113114 return BypassResult (
114- result_url = data .get ("resultUrl " ) or data .get ("result " , "" ),
115+ result_url = data .get ("result " ) or data .get ("resultUrl " , "" ),
115116 cached = data .get ("cached" , False ),
116117 process_time = data .get ("processTime" ),
117118 request_id = data .get ("requestId" ),
@@ -218,7 +219,11 @@ async def _arequest(self, method: str, path: str, body: Optional[dict] = None) -
218219 kwargs = {
219220 "method" : method ,
220221 "url" : url ,
221- "headers" : {"x-api-key" : self ._api_key , "Content-Type" : "application/json" },
222+ "headers" : {
223+ "x-api-key" : self ._api_key ,
224+ "Content-Type" : "application/json" ,
225+ "User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/124.0.0.0 Safari/537.36" ,
226+ },
222227 "timeout" : aiohttp .ClientTimeout (total = self ._timeout ),
223228 }
224229 if body :
@@ -241,7 +246,7 @@ async def bypass(self, url: str, *, refresh: bool = False) -> BypassResult: # t
241246 raise BypassToolsError ("url is required" , "MISSING_URL" )
242247 data = await self ._arequest ("POST" , "/bypass/direct" , {"url" : url , "refresh" : refresh })
243248 return BypassResult (
244- result_url = data .get ("resultUrl " ) or data .get ("result " , "" ),
249+ result_url = data .get ("result " ) or data .get ("resultUrl " , "" ),
245250 cached = data .get ("cached" , False ),
246251 process_time = data .get ("processTime" ),
247252 request_id = data .get ("requestId" ),
0 commit comments