This commit is contained in:
naibo 2023-12-15 17:14:06 +08:00
parent d13cd29fac
commit 7511de816c
7 changed files with 16 additions and 5 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

Binary file not shown.

Binary file not shown.

View File

@ -12,7 +12,7 @@
"justMyCode": false, "justMyCode": false,
// "args": ["--ids", "[7]", "--read_type", "remote", "--headless", "0"] // "args": ["--ids", "[7]", "--read_type", "remote", "--headless", "0"]
// "args": ["--ids", "[9]", "--read_type", "remote", "--headless", "0", "--saved_file_name", "YOUTUBE"] // "args": ["--ids", "[9]", "--read_type", "remote", "--headless", "0", "--saved_file_name", "YOUTUBE"]
"args": ["--ids", "[58]", "--headless", "0", "--user_data", "0", "--keyboard", "0", "args": ["--ids", "[1]", "--headless", "0", "--user_data", "0", "--keyboard", "0",
"--read_type", "remote"] "--read_type", "remote"]
// "args": "--ids '[97]' --user_data 1 --server_address http://localhost:8074 --config_folder '/Users/naibo/Documents/EasySpider/ElectronJS/' --headless 0 --read_type remote --config_file_name config.json --saved_file_name" // "args": "--ids '[97]' --user_data 1 --server_address http://localhost:8074 --config_folder '/Users/naibo/Documents/EasySpider/ElectronJS/' --headless 0 --read_type remote --config_file_name config.json --saved_file_name"
} }

View File

@ -1115,10 +1115,18 @@ class BrowserThread(Thread):
if node["parameters"]["exitCount"] == 0: if node["parameters"]["exitCount"] == 0:
# newBodyText = self.browser.find_element(By.XPATH, node["parameters"]["exitElement"], iframe=node["parameters"]["iframe"]).text # newBodyText = self.browser.find_element(By.XPATH, node["parameters"]["exitElement"], iframe=node["parameters"]["iframe"]).text
# 用find_elements获取所有匹配到的文本 # 用find_elements获取所有匹配到的文本
try:
exitElements = self.browser.find_elements(By.XPATH, node["parameters"]["exitElement"], iframe=node["parameters"]["iframe"]) exitElements = self.browser.find_elements(By.XPATH, node["parameters"]["exitElement"], iframe=node["parameters"]["iframe"])
newBodyText = "" newBodyText = ""
for exitElement in exitElements: for exitElement in exitElements:
newBodyText += exitElement.text newBodyText += exitElement.text
except Exception as e:
self.print_and_log(f"设定的退出循环元素:{node['parameters']['exitElement']}的文本无法获取本次循环将不再检测元素文本是否变化将会继续执行为解决此问题您可以修改检测元素文本不变的元素为其他元素或者将循环次数设定为固定次数大于0的值。")
self.print_and_log(f"The text of the exit loop element set: {node['parameters']['exitElement']} cannot be obtained, this loop will no longer check whether the text of the element has changed, and will continue to execute. To solve this problem, you can modify the element whose text does not change to other elements, or set the number of loops to a fixed number greater than 0.")
self.print_and_log(e)
exitElements = []
# newBodyText为随机文本保证一直执行
newBodyText = str(random.random())
if node["parameters"]["iframe"]: # 如果标记了iframe if node["parameters"]["iframe"]: # 如果标记了iframe
iframes = self.browser.find_elements( iframes = self.browser.find_elements(
By.CSS_SELECTOR, "iframe", iframe=False) By.CSS_SELECTOR, "iframe", iframe=False)