From d5b5dfa87fee3a8ed1dcb4a07de6b3542fe730dd Mon Sep 17 00:00:00 2001 From: naibo Date: Sun, 13 Aug 2023 23:51:18 +0800 Subject: [PATCH] Bug fix for element wait --- .temp_to_pub/EasySpider_windows_x64/tasks/207.json | 1 + .temp_to_pub/EasySpider_windows_x64/tasks/208.json | 1 + ExecuteStage/.vscode/launch.json | 2 +- ExecuteStage/easyspider_executestage.py | 4 ++-- 4 files changed, 5 insertions(+), 3 deletions(-) create mode 100644 .temp_to_pub/EasySpider_windows_x64/tasks/207.json create mode 100644 .temp_to_pub/EasySpider_windows_x64/tasks/208.json diff --git a/.temp_to_pub/EasySpider_windows_x64/tasks/207.json b/.temp_to_pub/EasySpider_windows_x64/tasks/207.json new file mode 100644 index 0000000..c7922e7 --- /dev/null +++ b/.temp_to_pub/EasySpider_windows_x64/tasks/207.json @@ -0,0 +1 @@ +{"id":207,"name":"淘宝","url":"https://www.taobao.com","links":"https://www.taobao.com","create_time":"8/11/2023, 4:38:10 PM","update_time":"8/11/2023, 4:38:10 PM","version":"0.5.0","saveThreshold":10,"cloudflare":0,"environment":0,"maxViewLength":15,"recordLog":1,"outputFormat":"xlsx","saveName":"current_time","inputExcel":"","startFromExit":0,"containJudge":false,"desc":"https://www.taobao.com","inputParameters":[{"id":0,"name":"urlList_0","nodeId":1,"nodeName":"打开网页","value":"https://www.taobao.com","desc":"要采集的网址列表,多行以\\n分开","type":"text","exampleValue":"https://www.taobao.com"},{"id":1,"name":"inputText_1","nodeName":"输入文字","nodeId":2,"desc":"要输入的文本,如京东搜索框输入:电脑","type":"text","exampleValue":"123","value":"123"}],"outputParameters":[],"graph":[{"index":0,"id":0,"parentId":0,"type":-1,"option":0,"title":"root","sequence":[1,2,3],"parameters":{"history":1,"tabIndex":0,"useLoop":false,"xpath":"","iframe":false,"wait":0,"waitType":0,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"waitElement":"","waitElementTime":10,"waitElementIframeIndex":0},"isInLoop":false},{"id":1,"index":1,"parentId":0,"type":0,"option":1,"title":"打开网页","sequence":[],"isInLoop":false,"position":0,"parameters":{"useLoop":false,"xpath":"","wait":0,"waitType":0,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"waitElement":"","waitElementTime":10,"waitElementIframeIndex":0,"url":"https://www.taobao.com","links":"https://www.taobao.com","maxWaitTime":10,"scrollType":0,"scrollCount":1,"scrollWaitTime":1,"cookies":""}},{"id":2,"index":2,"parentId":0,"type":0,"option":4,"title":"输入文字","sequence":[],"isInLoop":false,"position":1,"parameters":{"history":4,"tabIndex":-1,"useLoop":false,"xpath":"//*[@id=\"q\"]","iframe":false,"wait":0,"waitType":0,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"waitElement":"","waitElementTime":10,"waitElementIframeIndex":0,"value":"123","index":0,"allXPaths":["/html/body/div[2]/div[1]/div[1]/div[2]/div[1]/div[1]/form[1]/div[3]/input[1]","//input[contains(., '')]","id(\"q\")","//INPUT[@name='q']","/html/body/div[last()-13]/div/div/div[last()-1]/div/div[last()-1]/form/div/input"]}},{"id":3,"index":3,"parentId":0,"type":0,"option":2,"title":"点击元素","sequence":[],"isInLoop":false,"position":2,"parameters":{"history":4,"tabIndex":-1,"useLoop":false,"xpath":"//*[contains(@class, \"btn-search\")]","iframe":false,"wait":2,"waitType":0,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"waitElement":"","waitElementTime":10,"waitElementIframeIndex":0,"scrollType":0,"scrollCount":1,"scrollWaitTime":1,"clickWay":0,"maxWaitTime":10,"paras":[],"allXPaths":["/html/body/div[2]/div[1]/div[1]/div[2]/div[1]/div[1]/form[1]/div[1]/button[1]","//button[contains(., '搜索')]","//BUTTON[@class='btn-search tb-bg']","/html/body/div[last()-14]/div/div/div[last()-1]/div/div[last()-1]/form/div[last()-2]/button"]}}]} \ No newline at end of file diff --git a/.temp_to_pub/EasySpider_windows_x64/tasks/208.json b/.temp_to_pub/EasySpider_windows_x64/tasks/208.json new file mode 100644 index 0000000..1a6e50c --- /dev/null +++ b/.temp_to_pub/EasySpider_windows_x64/tasks/208.json @@ -0,0 +1 @@ +{"id":208,"name":"Yes, Captcha! - Login - 三六五日志","url":"http://yescaptcha.com/auth/login?next=%2Fdashboard.html","links":"http://yescaptcha.com/auth/login?next=%2Fdashboard.html","create_time":"8/13/2023, 11:08:43 PM","update_time":"8/13/2023, 11:35:38 PM","version":"0.5.0","saveThreshold":10,"cloudflare":0,"environment":0,"maxViewLength":15,"recordLog":1,"outputFormat":"xlsx","saveName":"current_time","inputExcel":"","startFromExit":0,"containJudge":false,"desc":"http://yescaptcha.com/auth/login?next=%2Fdashboard.html","inputParameters":[{"id":0,"name":"urlList_0","nodeId":1,"nodeName":"打开网页","value":"http://yescaptcha.com/auth/login?next=%2Fdashboard.html","desc":"要采集的网址列表,多行以\\n分开","type":"text","exampleValue":"http://yescaptcha.com/auth/login?next=%2Fdashboard.html"},{"id":1,"name":"inputText_1","nodeName":"输入文字","nodeId":2,"desc":"要输入的文本,如京东搜索框输入:电脑","type":"text","exampleValue":"i","value":"i"}],"outputParameters":[],"graph":[{"index":0,"id":0,"parentId":0,"type":-1,"option":0,"title":"root","sequence":[1,2],"parameters":{"history":1,"tabIndex":0,"useLoop":false,"xpath":"","iframe":false,"wait":0,"waitType":0,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"waitElement":"","waitElementTime":10,"waitElementIframeIndex":0},"isInLoop":false},{"id":1,"index":1,"parentId":0,"type":0,"option":1,"title":"打开网页","sequence":[],"isInLoop":false,"position":0,"parameters":{"useLoop":false,"xpath":"","wait":0,"waitType":0,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"waitElement":"","waitElementTime":10,"waitElementIframeIndex":0,"url":"http://yescaptcha.com/auth/login?next=%2Fdashboard.html","links":"http://yescaptcha.com/auth/login?next=%2Fdashboard.html","maxWaitTime":100,"scrollType":0,"scrollCount":1,"scrollWaitTime":1,"cookies":""}},{"id":2,"index":2,"parentId":0,"type":0,"option":4,"title":"输入文字","sequence":[],"isInLoop":false,"position":1,"parameters":{"history":4,"tabIndex":-1,"useLoop":false,"xpath":"//*[@id=\"email\"]","iframe":false,"wait":11,"waitType":0,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"waitElement":"/html/body/main/section/div/div/div/div[1]/div[2]/span/div[21]","waitElementTime":10,"waitElementIframeIndex":0,"value":"i","index":0,"allXPaths":["/html/body/main[1]/section[1]/div[1]/div[1]/div[1]/div[1]/form[1]/div[1]/div[1]/input[1]","//input[contains(., '')]","id(\"email\")","//INPUT[@class='input form-control']","//INPUT[@name='email']","/html/body/main/section/div/div/div/div[last()-1]/form/div[last()-3]/div/input"]}}]} \ No newline at end of file diff --git a/ExecuteStage/.vscode/launch.json b/ExecuteStage/.vscode/launch.json index ce6f3fc..442d3f8 100644 --- a/ExecuteStage/.vscode/launch.json +++ b/ExecuteStage/.vscode/launch.json @@ -12,7 +12,7 @@ "justMyCode": false, // "args": ["--id", "[7]", "--read_type", "remote", "--headless", "0"] // "args": ["--id", "[9]", "--read_type", "remote", "--headless", "0", "--saved_file_name", "YOUTUBE"] - "args": ["--id", "[28]", "--headless", "0", "--user_data", "0", "--keyboard", "0"] + "args": ["--id", "[11]", "--headless", "0", "--user_data", "0", "--keyboard", "0"] } ] } \ No newline at end of file diff --git a/ExecuteStage/easyspider_executestage.py b/ExecuteStage/easyspider_executestage.py index a101350..48b7b6f 100644 --- a/ExecuteStage/easyspider_executestage.py +++ b/ExecuteStage/easyspider_executestage.py @@ -711,7 +711,7 @@ class BrowserThread(Thread): waitElement = replace_field_values( node["parameters"]["waitElement"], self.outputParameters) waitElementTime = float(node["parameters"]["waitElementTime"]) - waitElementIframeIndex = node["parameters"]["waitElementInIframe"] + waitElementIframeIndex = node["parameters"]["waitElementIframeIndex"] self.print_and_log("等待元素出现:", waitElement) self.print_and_log( "Waiting for element to appear:", waitElement) @@ -730,7 +730,7 @@ class BrowserThread(Thread): self.print_and_log("等待元素出现超时:", waitElement, ",将继续执行。") self.print_and_log("Timeout waiting for element to appear:", waitElement, ", will continue to execute.") - self.print_and_log(e) + self.recordLog(e) self.recordLog("Wait element not found") self.recordLog("执行节点|Execute node:", node["title"]) # 根据不同选项执行不同操作