wangkun 2 年之前
父節點
當前提交
92238fb7c7
共有 1 個文件被更改,包括 2 次插入3 次删除
  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):
     def check_to_webview(cls, log_type, crawler, driver: WebDriver):
         webviews = driver.contexts
         webviews = driver.contexts
         Common.logger(log_type, crawler).info(f"webviews:{webviews}")
         Common.logger(log_type, crawler).info(f"webviews:{webviews}")
-        # for webview in webviews:
         driver.switch_to.context(webviews[1])
         driver.switch_to.context(webviews[1])
-        # driver.switch_to.context('WEBVIEW_com.tencent.mm:tools')
         time.sleep(1)
         time.sleep(1)
         windowHandles = driver.window_handles
         windowHandles = driver.window_handles
         for handle in windowHandles:
         for handle in windowHandles:
             driver.switch_to.window(handle)
             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 成功')
                 Common.logger(log_type, crawler).info('切换 webview 成功')
                 return "成功"
                 return "成功"
             else:
             else: