|
@@ -245,15 +245,17 @@ class ShipinhaoSearch:
|
|
|
webviews = driver.contexts
|
|
|
Common.logger(log_type, crawler).info(f"webviews:{webviews}")
|
|
|
driver.switch_to.context(webviews[1])
|
|
|
+ Common.logger(log_type, crawler).info(driver.current_context)
|
|
|
time.sleep(1)
|
|
|
windowHandles = driver.window_handles
|
|
|
for handle in windowHandles:
|
|
|
- driver.switch_to.window(handle)
|
|
|
- time.sleep(1)
|
|
|
- if driver.find_element(By.XPATH, '//div[@class="unit"]'):
|
|
|
+ try:
|
|
|
+ driver.switch_to.window(handle)
|
|
|
+ time.sleep(1)
|
|
|
+ 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
|