Deal with data:

This commit is contained in:
naibo 2023-11-23 06:33:18 +08:00
parent 4025e255a0
commit c197ff1970
4 changed files with 34 additions and 10 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -894,6 +894,7 @@ class BrowserThread(Thread):
thisHistoryLength = 0 thisHistoryLength = 0
self.history["index"] = thisHistoryLength self.history["index"] = thisHistoryLength
self.history["handle"] = thisHandle self.history["handle"] = thisHandle
thisHitoryURL = self.browser.current_url
if int(node["parameters"]["loopType"]) == 0: # 单个元素循环 if int(node["parameters"]["loopType"]) == 0: # 单个元素循环
# 无跳转标签页操作 # 无跳转标签页操作
count = 0 # 执行次数 count = 0 # 执行次数
@ -1033,11 +1034,16 @@ class BrowserThread(Thread):
self.browser.execute_script('window.stop()') self.browser.execute_script('window.stop()')
except: except:
pass pass
ti = 0
if self.browser.current_url.startswith("data:"): if self.browser.current_url.startswith("data:"):
while self.browser.current_url != thisHitoryURL: # 如果执行完一次循环之后网址发生了变化
try: try:
self.browser.execute_script("history.go(1)") # 如果是data:开头的网址,就前进一步 self.browser.execute_script("history.go(1)") # 如果是data:开头的网址,就前进一步
except: # 超时的情况下 except: # 超时的情况下
pass pass
ti += 1
if self.browser.current_url == thisHitoryURL or ti > thisHistoryLength: # 如果执行完一次循环之后网址发生了变化
break
time.sleep(2) time.sleep(2)
elements = self.browser.find_elements(By.XPATH, elements = self.browser.find_elements(By.XPATH,
xpath, iframe=node["parameters"]["iframe"]) xpath, iframe=node["parameters"]["iframe"])
@ -1110,11 +1116,26 @@ class BrowserThread(Thread):
self.browser.execute_script('window.stop()') self.browser.execute_script('window.stop()')
except: except:
pass pass
# if self.browser.current_url.startswith("data:"):
# try:
# self.browser.execute_script("history.go(1)") # 如果是data:开头的网址,就前进一步
# except: # 超时的情况下
# pass
# time.sleep(2)
# elements = self.browser.find_elements(By.XPATH,
# xpath, iframe=node["parameters"]["iframe"])
# if index > 0:
# index -= 1 # 如果是data:开头的网址,就要重试一次
ti = 0
if self.browser.current_url.startswith("data:"): if self.browser.current_url.startswith("data:"):
while self.browser.current_url != thisHitoryURL: # 如果执行完一次循环之后网址发生了变化
try: try:
self.browser.execute_script("history.go(1)") # 如果是data:开头的网址,就前进一步 self.browser.execute_script("history.go(1)") # 如果是data:开头的网址,就前进一步
except: # 超时的情况下 except: # 超时的情况下
pass pass
ti += 1
if self.browser.current_url == thisHitoryURL or ti > thisHistoryLength: # 如果执行完一次循环之后网址发生了变化
break
time.sleep(2) time.sleep(2)
elements = self.browser.find_elements(By.XPATH, elements = self.browser.find_elements(By.XPATH,
xpath, iframe=node["parameters"]["iframe"]) xpath, iframe=node["parameters"]["iframe"])