diff --git a/logic_anilife.py b/logic_anilife.py index fea0dde..132f556 100644 --- a/logic_anilife.py +++ b/logic_anilife.py @@ -6,6 +6,7 @@ from datetime import datetime import hashlib import re import asyncio +import platform import lxml.etree @@ -15,7 +16,13 @@ from lxml import html from urllib import parse import urllib -packages = ["beautifulsoup4", "requests-cache", "cloudscraper", "selenium_stealth", "webdriver_manager"] +packages = [ + "beautifulsoup4", + "requests-cache", + "cloudscraper", + "selenium_stealth", + "webdriver_manager", +] for package in packages: try: import package @@ -80,6 +87,8 @@ class LogicAniLife(LogicModuleBase): episode_url = None cookies = None + os_platform = platform.system() + session = requests.Session() headers = { "User-Agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36", @@ -383,12 +392,18 @@ class LogicAniLife(LogicModuleBase): options.add_argument("--no-sandbox") options.add_experimental_option("excludeSwitches", ["enable-automation"]) options.add_experimental_option("useAutomationExtension", False) - # 크롬드라이버 경로 - driver_path = "./bin/Darwin/chromedriver" - # driver = webdriver.Chrome(executable_path=driver_path, chrome_options=options) - driver = webdriver.Chrome( - ChromeDriverManager().install(), chrome_options=options - ) + + if LogicAniLife.os_platform == 'Darwin': + # 크롬드라이버 경로 + driver_path = "./bin/Darwin/chromedriver" + # driver = webdriver.Chrome(executable_path=driver_path, chrome_options=options) + driver = webdriver.Chrome( + ChromeDriverManager().install(), chrome_options=options + ) + else: + driver_path = f"./bin/{LogicAniLife.os_platform}/chromedriver" + driver = webdriver.Chrome(executable_path=driver_path, chrome_options=options) + stealth( driver, languages=["en-US", "en"],