|
@@ -243,18 +243,18 @@ 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(webview)
|
|
|
- time.sleep(1)
|
|
|
- windowHandles = driver.window_handles
|
|
|
- for handle in windowHandles:
|
|
|
- driver.switch_to.window(handle)
|
|
|
- try:
|
|
|
- driver.find_element(By.XPATH, '//div[@class="unit"]')
|
|
|
- Common.logger(log_type, crawler).info('切换 webview 成功')
|
|
|
- return "成功"
|
|
|
- except Exception:
|
|
|
- Common.logger(log_type, crawler).info("切换 webview 失败")
|
|
|
+ # 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"]'):
|
|
|
+ Common.logger(log_type, crawler).info('切换 webview 成功')
|
|
|
+ return "成功"
|
|
|
+ else:
|
|
|
+ Common.logger(log_type, crawler).info("切换 webview 失败")
|
|
|
|
|
|
@classmethod
|
|
|
def repeat_out_video_id(cls, log_type, crawler, out_video_id, env):
|