2022.01.30 버그 픽스

This commit is contained in:
2023-01-30 19:26:57 +09:00
parent a9ea8f193f
commit cae6985aec
5 changed files with 888 additions and 187 deletions

View File

@@ -18,6 +18,9 @@ from lxml import html
from urllib import parse
import urllib
# my
from .lib.utils import yommi_timeit
packages = [
"beautifulsoup4",
"requests-cache",
@@ -590,7 +593,18 @@ class LogicAniLife(LogicModuleBase):
await browser.close()
@staticmethod
def get_html_selenium(url: str, referer: str) -> bytes:
@yommi_timeit
def get_html_selenium(
url: str,
referer: str,
headless=True,
linux=True,
maximize=True,
user_agent=False,
lang_kr=False,
secret_mode=False,
download_path=None,
) -> bytes:
from selenium.webdriver.common.by import By
from selenium import webdriver
from selenium_stealth import stealth
@@ -598,16 +612,44 @@ class LogicAniLife(LogicModuleBase):
import time
options = webdriver.ChromeOptions()
# options.add_experimental_option('excludeSwitches', ['enable-logging'])
# 크롬드라이버 헤더 옵션추가 (리눅스에서 실행시 필수)
options.add_argument("start-maximized")
options.add_argument("--headless")
if headless:
options.add_argument("--headless")
options.add_argument("--no-sandbox")
options.add_argument("window-size=1920x1080")
options.add_argument("disable-gpu")
# options.add_argument('--no-sandbox')
options.add_argument("--disable-dev-shm-usage")
options.add_experimental_option("excludeSwitches", ["enable-automation"])
# 크롬 드라이버에 setuid를 하지 않음으로써 크롬의 충돌 막음
options.add_argument("--disable-setuid-sandbox")
# disabling extensions
options.add_argument("--disable-extensions")
if download_path:
pass
if maximize:
options.add_argument("start-maximized")
# 일단 좀 더 확인 필요
options.add_experimental_option(
"excludeSwitches", ["enable-automation", "enable-logging"]
)
options.add_experimental_option("useAutomationExtension", False)
options.add_argument("--single-process")
if user_agent:
options.add_argument(
"user-agent=Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 "
"Safari/537.36"
)
if lang_kr:
options.add_argument("--lang=ko_KR")
if secret_mode:
options.add_argument("--incognito")
if LogicAniLife.os_platform == "Darwin":
# 크롬드라이버 경로
@@ -616,6 +658,7 @@ class LogicAniLife(LogicModuleBase):
driver = webdriver.Chrome(
ChromeDriverManager().install(), chrome_options=options
)
else:
# driver_bin_path = os.path.join(
# os.path.dirname(__file__), "bin", f"{LogicAniLife.os_platform}"
@@ -628,6 +671,8 @@ class LogicAniLife(LogicModuleBase):
ChromeDriverManager().install(), chrome_options=options
)
driver.implicitly_wait(5)
stealth(
driver,
languages=["ko-KR", "ko"],