update 0.0.6.2

This commit is contained in:
HibiKi
2021-11-23 21:44:59 +08:00
parent c802dfda22
commit 3de487fb24
251 changed files with 14413 additions and 14002 deletions
+27 -31
View File
@@ -2,10 +2,9 @@ from lxml import etree
import feedparser
from urllib import parse
from services.log import logger
from utils.http_utils import AsyncHttpx
from typing import List
import aiohttp
import time
from utils.utils import get_local_proxy
async def from_anime_get_info(key_word: str, max_: int) -> List[str]:
@@ -22,35 +21,32 @@ async def from_anime_get_info(key_word: str, max_: int) -> List[str]:
async def get_repass(url: str, max_: int) -> List[str]:
put_line = []
async with aiohttp.ClientSession() as session:
async with session.get(url, proxy=get_local_proxy(), timeout=20) as response:
d = feedparser.parse(await response.text())
max_ = max_ if max_ < len([e.link for e in d.entries]) else len([e.link for e in d.entries])
url_list = [e.link for e in d.entries][:max_]
for u in url_list:
try:
async with session.get(
u, proxy=get_local_proxy(), timeout=20
) as res:
html = etree.HTML(await res.text())
magent = html.xpath('.//a[@id="a_magnet"]/text()')[0]
title = html.xpath(".//h3/text()")[0]
item = html.xpath(
'//div[@class="info resource-info right"]/ul/li'
)
class_a = (
item[0]
.xpath("string(.)")[5:]
.strip()
.replace("\xa0", "")
.replace("\t", "")
)
size = item[3].xpath("string(.)")[5:].strip()
put_line.append(
"【{}】| {}\n【{}】| {}".format(class_a, title, size, magent)
)
except Exception as e:
logger.warning(f"搜番超时 e:{e}")
text = (await AsyncHttpx.get(url)).text
d = feedparser.parse(text)
max_ = max_ if max_ < len([e.link for e in d.entries]) else len([e.link for e in d.entries])
url_list = [e.link for e in d.entries][:max_]
for u in url_list:
try:
text = (await AsyncHttpx.get(u)).text
html = etree.HTML(text)
magent = html.xpath('.//a[@id="a_magnet"]/text()')[0]
title = html.xpath(".//h3/text()")[0]
item = html.xpath(
'//div[@class="info resource-info right"]/ul/li'
)
class_a = (
item[0]
.xpath("string(.)")[5:]
.strip()
.replace("\xa0", "")
.replace("\t", "")
)
size = item[3].xpath("string(.)")[5:].strip()
put_line.append(
"【{}】| {}\n【{}】| {}".format(class_a, title, size, magent)
)
except Exception as e:
logger.error(f"搜番发生错误 {type(e)}:{e}")
return put_line