From 4e5498d6c81a8d1dfe5e9669919a360046a3f940 Mon Sep 17 00:00:00 2001 From: projectdx Date: Tue, 27 Sep 2022 13:08:25 +0900 Subject: [PATCH] =?UTF-8?q?=EC=95=A0=EB=8B=88=EB=9D=BC=EC=9D=B4=ED=94=84?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80=20=EB=B0=8F=20=EC=95=A0=EB=8B=8824=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=202022.09.25?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit os platform fix --- logic_anilife.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) 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"],