wangkun 2 năm trước cách đây
mục cha
commit
777c7ffc62
1 tập tin đã thay đổi với 3 bổ sung2 xóa
  1. 3 2
      shipinhao/shipinhao_search/shipinhao_search.py

+ 3 - 2
shipinhao/shipinhao_search/shipinhao_search.py

@@ -249,10 +249,11 @@ class ShipinhaoSearch:
             windowHandles = driver.window_handles
             for handle in windowHandles:
                 driver.switch_to.window(handle)
-                if driver.find_element(By.XPATH, '//div[@class="unit"]'):
+                try:
+                    driver.find_element(By.XPATH, '//div[@class="unit"]')
                     Common.logger(log_type, crawler).info('切换 webview 成功')
                     return "成功"
-                else:
+                except Exception:
                     Common.logger(log_type, crawler).info("切换 webview 失败")
 
     @classmethod