Spaces:
Running
Running
rogerxavier
commited on
Update server/resource.py
Browse files- server/resource.py +7 -3
server/resource.py
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
# -*- coding: utf-8 -*-
|
3 |
import requests
|
4 |
from .utils import headers
|
5 |
-
|
6 |
|
7 |
class Resource:
|
8 |
def __init__(self, url: str):
|
@@ -11,8 +11,12 @@ class Resource:
|
|
11 |
self._get_resource()
|
12 |
|
13 |
def _get_resource(self) -> None:
|
14 |
-
|
15 |
-
|
|
|
|
|
|
|
|
|
16 |
|
17 |
def get_encoded_data(self) -> str:
|
18 |
return self.cutted_str + ((4 - len(self.cutted_str) % 4) * "=")
|
|
|
2 |
# -*- coding: utf-8 -*-
|
3 |
import requests
|
4 |
from .utils import headers
|
5 |
+
|
6 |
|
7 |
class Resource:
|
8 |
def __init__(self, url: str):
|
|
|
11 |
self._get_resource()
|
12 |
|
13 |
def _get_resource(self) -> None:
|
14 |
+
try:
|
15 |
+
request = requests.get(self.url, headers=headers)
|
16 |
+
self.cutted_str = request.text
|
17 |
+
except Exception as e:
|
18 |
+
print(f"请求失败,使用之前的cutted_str",self.cutted_str)
|
19 |
+
|
20 |
|
21 |
def get_encoded_data(self) -> str:
|
22 |
return self.cutted_str + ((4 - len(self.cutted_str) % 4) * "=")
|