wangkun před 1 rokem
rodič
revize
92238fb7c7
1 změnil soubory, kde provedl 2 přidání a 3 odebrání
  1. 2 3
      shipinhao/shipinhao_search/shipinhao_search.py

+ 2 - 3
shipinhao/shipinhao_search/shipinhao_search.py

@@ -243,14 +243,13 @@ class ShipinhaoSearch:
     def check_to_webview(cls, log_type, crawler, driver: WebDriver):
         webviews = driver.contexts
         Common.logger(log_type, crawler).info(f"webviews:{webviews}")
-        # for webview in webviews:
         driver.switch_to.context(webviews[1])
-        # driver.switch_to.context('WEBVIEW_com.tencent.mm:tools')
         time.sleep(1)
         windowHandles = driver.window_handles
         for handle in windowHandles:
             driver.switch_to.window(handle)
-            if driver.find_element(By.XPATH, '//div[@class="unit"]'):
+            time.sleep(1)
+            if len(driver.find_elements(By.XPATH, '//div[@class="unit"]')) != 0:
                 Common.logger(log_type, crawler).info('切换 webview 成功')
                 return "成功"
             else: