更新代码

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: class Download:
def __init__( def __init__(
self, self,
path,
headers: dict, headers: dict,
proxies=None, ): proxies=None, ):
self.root = Path(path)
self.headers = headers self.headers = headers
self.proxies = { self.proxies = {
"http": proxies, "http": proxies,

View File

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

View File

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

View File

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