更新代码

This commit is contained in:
JoeamAmier 2023-08-26 10:56:22 +08:00
parent 250139be3c
commit 780c42f9b8
4 changed files with 11 additions and 6 deletions

View File

@ -1,8 +1,13 @@
from pathlib import Path
class Download:
def __init__(
self,
path,
headers: dict,
proxies=None, ):
self.root = Path(path)
self.headers = headers
self.proxies = {
"http": proxies,

View File

@ -5,7 +5,7 @@ class Image:
IMAGE_API = "https://sns-img-qc.xhscdn.com/"
IMAGE_ID = compile(r'"traceId":"(.*?)"')
def __init__(self, html: str):
def __init__(self, html):
self.html = html
def get_image_link(self, url: str, download: bool):

View File

@ -4,7 +4,7 @@ from re import compile
class Video:
VIDEO_ID = compile(r'"masterUrl":"(.*?)"')
def __init__(self, html: str):
def __init__(self, html):
self.html = html
def get_video_link(self, url: str, download: bool):

View File

@ -1,6 +1,6 @@
from .Download import Download
from .Html import Html
from .Image import Image
from .Params import Params
from .Video import Video
HEADERS = {
@ -11,10 +11,10 @@ HEADERS = {
class XHS:
def __init__(self, path="./", headers=None, proxies=None, timeout=10):
self.params = Params(path)
self.html = Html(headers or HEADERS, proxies, timeout)
self.image = Image(self.html, self.params)
self.video = Video(self.html, self.params)
self.image = Image(self.html)
self.video = Video(self.html)
self.download = Download(path, self.html.headers, proxies)
self._cookie = ""
def get_image(self, url: str, download=False):