fix: test

This commit is contained in:
EstrellaXD
2023-08-12 15:50:13 +08:00
parent dd5c918703
commit cb7aef19c4
3 changed files with 19 additions and 13 deletions

View File

@@ -35,19 +35,6 @@ class RequestContent(RequestURL):
except ConnectionError:
return []
def get_mikan_info(self, _url) -> tuple[str, str]:
content = self.get_html(_url)
soup = BeautifulSoup(content, "html.parser")
poster_div = soup.find("div", {"class": "bangumi-poster"})
poster_style = poster_div.get("style")
official_title = soup.select_one(
'p.bangumi-title a[href^="/Home/Bangumi/"]'
).text
if poster_style:
poster_path = poster_style.split("url('")[1].split("')")[0]
return poster_path, official_title
return "", ""
def get_xml(self, _url, retry: int = 3) -> xml.etree.ElementTree.Element:
return xml.etree.ElementTree.fromstring(self.get_url(_url, retry).text)

View File

@@ -1,3 +1,4 @@
from .raw_parser import raw_parser
from .tmdb_parser import tmdb_parser
from .torrent_parser import torrent_parser
from .mikan_parser import mikan_parser

View File

@@ -0,0 +1,18 @@
from bs4 import BeautifulSoup
from module.network import RequestContent
def mikan_parser(homepage: str):
with RequestContent() as req:
content = req.get_html(homepage)
soup = BeautifulSoup(content, "html.parser")
poster_div = soup.find("div", {"class": "bangumi-poster"})
poster_style = poster_div.get("style")
official_title = soup.select_one(
'p.bangumi-title a[href^="/Home/Bangumi/"]'
).text
if poster_style:
poster_path = poster_style.split("url('")[1].split("')")[0]
return poster_path, official_title
return "", ""