uu_pixiv_api / server /resource.py
rogerxavier's picture
Update server/resource.py
66622b8 verified
raw
history blame
611 Bytes
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import requests
from .utils import headers
class Resource:
def __init__(self, url: str):
self.url = url
self.cutted_str: str
self._get_resource()
def _get_resource(self) -> None:
try:
request = requests.get(self.url, headers=headers)
self.cutted_str = request.text
except Exception as e:
print(f"请求失败,使用之前的cutted_str",self.cutted_str)
def get_encoded_data(self) -> str:
return self.cutted_str + ((4 - len(self.cutted_str) % 4) * "=")