diff --git a/hasaki_crawler_engine/hasaki_product_info.py b/hasaki_crawler_engine/hasaki_product_info.py index 297833c..a1e12f3 100644 --- a/hasaki_crawler_engine/hasaki_product_info.py +++ b/hasaki_crawler_engine/hasaki_product_info.py @@ -92,12 +92,20 @@ class HasakiProductInfo: for _ in range(retries): try: with sync_playwright() as p: - browser = p.chromium.launch(headless=False) + browser = p.chromium.launch( + headless=False, + args=[ + "--disable-dev-shm-usage", + "--disable-blink-features=AutomationControlled", + "--disable-component-extensions-with-background-pages" + ] + ) ua = UserAgent(platforms='mobile') random_mobile_ua = ua.random logging.info("using user agent: {}".format(random_mobile_ua)) context = browser.new_context(user_agent=random_mobile_ua) + context.add_init_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})") page = context.new_page() api_requests = {} diff --git a/hasaki_crawler_engine/test.py b/hasaki_crawler_engine/test.py index 19eb9d2..6eb517f 100644 --- a/hasaki_crawler_engine/test.py +++ b/hasaki_crawler_engine/test.py @@ -6,12 +6,17 @@ import logging with sync_playwright() as p: - browser = p.chromium.launch(headless=False) + browser = p.chromium.launch(headless=False, args=[ + "--disable-dev-shm-usage", + "--disable-blink-features=AutomationControlled", + "--disable-component-extensions-with-background-pages" + ]) ua = UserAgent(platforms='mobile') random_mobile_ua = ua.random logging.info("using user agent: {}".format(random_mobile_ua)) context = browser.new_context(user_agent=random_mobile_ua) + context.add_init_script("Object.defineProperty(navigator, 'webdriver', {get: () => undefined})") page = context.new_page() try: