Przeglądaj źródła

自定义操作增加暂停执行功能,右键菜单增加很多功能,下载目录位置为任务文件夹位置

naibo 2 lat temu
rodzic
commit
7d72e2c71c

Plik diff jest za duży
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/74.json


Plik diff jest za duży
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/75.json


Plik diff jest za duży
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/76.json


Plik diff jest za duży
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/77.json


Plik diff jest za duży
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/78.json


Plik diff jest za duży
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/79.json


Plik diff jest za duży
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/80.json


Plik diff jest za duży
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/81.json


Plik diff jest za duży
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/82.json


Plik diff jest za duży
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/execution_instances/83.json


Plik diff jest za duży
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/tasks/210.json


Plik diff jest za duży
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/tasks/211.json


Plik diff jest za duży
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/tasks/226.json


Plik diff jest za duży
+ 0 - 0
.temp_to_pub/EasySpider_windows_x64/tasks/227.json


+ 5 - 1
ElectronJS/src/taskGrid/FlowChart.html

@@ -371,9 +371,13 @@
                         <option v-if="nowNode['isInLoop']" value = 4>Skip Current Loop (the "Continue" operation)</option>
                         <option value = 5>Run Python code on current environment (the "exec" operation)</option>
                         <option value = 6>Get value of a Python expression (the "eval" operation)</option>
+                        <option value = 7>Pause program execution (such as when the captcha box appears)</option>
                     </select>
+                    <div v-if='nowNode["parameters"]["codeMode"] == 7'>
+                        <label>This operation can pause program execution, such as when a captcha box appears, and it will not continue until you manually press and hold the p key.</label>
+                    </div>
 
-                    <div v-if='nowNode["parameters"]["codeMode"] < 3 || nowNode["parameters"]["codeMode"] >= 5'>
+                    <div v-if='nowNode["parameters"]["codeMode"] < 3 || nowNode["parameters"]["codeMode"] >= 5 && nowNode["parameters"]["codeMode"] <=6'>
                         <label>Code (Use Field["FieldName"] to input the lastest value of a field): </label>
                         <textarea onkeydown="inputDelete(event)" class="form-control" rows="2" v-model='nowNode["parameters"]["code"]' placeholder="Please input a JavaScript command or a system command. For example, document.body.innerText = '1' is an example of a JavaScript command, and python D:/test.py is an example of a system command. If you choose to execute a JavaScript script for the current iteration, you can represent the element of the current iteration using arguments[0]. For instance, arguments[0].style.color = 'blue' sets the color of the element in the current iteration to blue."></textarea>
                         <pre class="form-control" style="background: white; margin-top: 20px; min-height: 200px; font-size: 15px!important; word-wrap: break-word; white-space: pre-wrap; border-radius: 0; border: 1px solid" disabled v-if='nowNode["parameters"]["codeMode"] == 5'>Please read the instructions first and then write the specific code in the input box above (not in this box).

+ 66 - 37
ElectronJS/src/taskGrid/FlowChart.js

@@ -247,13 +247,13 @@ function newNode(node) {
     {
         return LANG(`<div class="loop clk" draggable="true" dataType=${type} data="${id}" position=${node["position"]} pId=${node["parentId"]}>
                     <p style="background:#d6d6d6;text-align:left;padding:2px">${title}</p>
-                    <p class="branchAdd" data="${id}">点击此处在最边增加条件分支</p>
+                    <p class="branchAdd" data="${id}">点击此处在最边增加条件分支</p>
                     <div class="judge" id = "${id}">
                     </div></div>
                     <p class="arrow" draggable="true" data = "${id}" position=${node["position"]} pId=${node["parentId"]}>↓</p></div>`,
             `<div class="loop clk" draggable="true" dataType=${type} data="${id}" position=${node["position"]} pId=${node["parentId"]}>
                     <p style="background:#d6d6d6;text-align:left;padding:2px">${title}</p>
-                    <p class="branchAdd" data="${id}">Click here to add a new condition to the left most</p>
+                    <p class="branchAdd" data="${id}">Click here to add a new condition to the right most</p>
                     <div class="judge" id = "${id}">
                     </div></div>
                     <p class="arrow" draggable="true" data = "${id}" position=${node["position"]} pId=${node["parentId"]}>↓</p></div>`);
@@ -269,31 +269,6 @@ function newNode(node) {
 
 
 
-function branchMouseDown(e) {
-    if (e.button == 2) //右键点击
-    {
-        let judgeId = this.getAttribute('data');
-        let l = nodeList.length;
-        let t = {
-            index: l,
-            id: 0,
-            parentId: 0,
-            type: 3,
-            option: 10,
-            title: LANG("条件分支", "Condition"),
-            sequence: [],
-            isInLoop: false,
-        };
-        addParameters(t)
-        nodeList.push(t);
-        nodeList[actionSequence[judgeId]]["sequence"].splice(0, 0, t.index);
-        refresh();
-        app._data.nowArrow = { "position": -1, "pId": t["id"], "num": 0 };
-        $("#" + t["id"]).click();
-    }
-    e.stopPropagation(); //防止冒泡
-}
-
 function arrowMouseDown(e) {
     if (e.button == 2) //右键点击
     {
@@ -313,13 +288,14 @@ function branchClick(e) {
         parentId: 0,
         type: 3,
         option: 10,
-        title: LANG("条件分支", "Condition"),
+        title: LANG("条件分支"+(nodeList[actionSequence[judgeId]]["sequence"].length+1).toString(), "Condition "+(l+1).toString()),
         sequence: [],
         isInLoop: false,
     };
     addParameters(t);
     nodeList.push(t);
-    nodeList[actionSequence[judgeId]]["sequence"].splice(0, 0, t.index);
+    // nodeList[actionSequence[judgeId]]["sequence"].splice(0, 0, t.index); //开头插入
+    nodeList[actionSequence[judgeId]]["sequence"].push(t.index); //结尾插入
     refresh();
     app._data.nowArrow = { "position": -1, "pId": t["id"], "num": 0 };
     $("#" + t["id"]).click();
@@ -504,7 +480,7 @@ function toolBoxKernel(e, para = null) {
                 index: l + 1,
                 type: 3,
                 option: 10,
-                title: LANG("条件分支", "Condition"),
+                title: LANG("条件分支1", "Condition 1"),
                 sequence: [],
                 isInLoop: false,
             };
@@ -514,7 +490,7 @@ function toolBoxKernel(e, para = null) {
                 index: l + 2,
                 type: 3,
                 option: 10,
-                title: LANG("条件分支", "Condition"),
+                title: LANG("条件分支2", "Condition 2"),
                 sequence: [],
                 isInLoop: false,
             };
@@ -636,8 +612,6 @@ function bindEvents() {
     for (let i = 0, rule; rule = branch[i++];) {
         rule.removeEventListener('click', branchClick);
         rule.addEventListener('click', branchClick);
-        rule.removeEventListener('mousedown', branchMouseDown);
-        rule.addEventListener('mousedown', branchMouseDown);
     }
     let options = document.getElementsByClassName("options");
     for (let i = 0, rule; rule = options[i++];) {
@@ -720,26 +694,81 @@ function deleteElement() {
     nowNode = null; //取消选择
 }
 
-document.oncontextmenu = function() {
+document.oncontextmenu = function(e) {
         // 创建一个包含删除选项的右键菜单
         let contextMenu = document.createElement("div");
         contextMenu.id = "contextMenu";
-        contextMenu.innerHTML = `<div>${LANG("删除元素(双击)", "Delete Element (Double Click)")}`;
+        contextMenu.innerHTML = `<div>${LANG("试运行","Test Run")}</div>
+        <div>${LANG("复制元素","Copy Element")}</div>
+        <div>${LANG("剪切元素","Move Element")}</div>
+        <div>${LANG("删除元素(双击)", "Delete Element (Double Click)")}</div>`;
+
+    if (nowNode.getAttribute("datatype") == 3) { //如果删掉的是条件分支的话
+        contextMenu.innerHTML += `<div>${LANG("前移","Move Up")}</div>
+<div>${LANG("后移","Move Down")}</div>`;
+        // Add 前移 functionality
+        contextMenu.children[4].addEventListener('click', function () {
+            let conditionId = parseInt(nowNode.getAttribute('pid'));
+            let position = parseInt(nowNode.getAttribute('position'));
+            if(position > 0){
+                nodeList[actionSequence[conditionId]]["sequence"][position] = nodeList[actionSequence[conditionId]]["sequence"][position - 1];
+                nodeList[actionSequence[conditionId]]["sequence"][position - 1] = actionSequence[parseInt(nowNode.getAttribute('data'))];
+                refresh();
+                app._data.nowArrow = { "position": -1, "pId": 0, "num": 0 };
+                $("#0").click();
+                e.stopPropagation(); //防止冒泡
+            }
+        });
+
+        // Add 后移 functionality
+        contextMenu.children[5].addEventListener('click', function () {
+            let conditionId = parseInt(nowNode.getAttribute('pid'));
+            let position = parseInt(nowNode.getAttribute('position'));
+            if(position < nodeList[actionSequence[conditionId]]["sequence"].length - 1){
+                nodeList[actionSequence[conditionId]]["sequence"][position] = nodeList[actionSequence[conditionId]]["sequence"][position + 1];
+                nodeList[actionSequence[conditionId]]["sequence"][position + 1] = actionSequence[parseInt(nowNode.getAttribute('data'))];
+                refresh();
+                app._data.nowArrow = { "position": -1, "pId": 0, "num": 0 };
+                $("#0").click();
+                e.stopPropagation(); //防止冒泡
+            }
+        });
+    }
 
         // 设置右键菜单的样式
         contextMenu.style.position = "absolute";
+        contextMenu.style.backgroundColor = "rgb(248, 249, 250)";
         contextMenu.style.left = event.clientX + "px";
         contextMenu.style.top = event.clientY + "px";
         contextMenu.style.width = LANG("180px", "250px");
 
         // 添加删除元素的功能
-        contextMenu.addEventListener("dblclick", function() {
+        contextMenu.children[3].addEventListener("dblclick", function() {
             // myElement.remove(); // 删除元素
             deleteElement();
             contextMenu.remove(); // 删除右键菜单
         });
 
-        // 将右键菜单添加到文档中
+        // Add Test Run functionality
+        contextMenu.children[0].addEventListener('click', function () {
+
+        });
+
+        // Add copy functionality
+        contextMenu.children[1].addEventListener('click', function () {
+            option = 11; //复制元素操作
+            showInfo(LANG("复制成功,请点击流程图中相应位置箭头以粘贴操作。", "Copy successfully, please click the arrow in the flow chart to paste."));
+            contextMenu.remove(); // Remove the context menu
+        });
+
+        // Add cut functionality
+        contextMenu.children[2].addEventListener('click', function () {
+            option = 10; //剪切元素操作
+            showInfo(LANG("剪切成功,请点击流程图中相应位置箭头以粘贴操作。", "Cut successfully, please click the arrow in the flow chart to paste."));
+            contextMenu.remove(); // Remove the context menu
+        });
+
+    // 将右键菜单添加到文档中
         document.body.appendChild(contextMenu);
     } //屏蔽右键菜单
     //删除元素

+ 5 - 2
ElectronJS/src/taskGrid/FlowChart_CN.html

@@ -372,9 +372,12 @@
                         <option v-if="nowNode['isInLoop']" value = 4>跳过当前循环后面的操作(Continue操作)</option>
                         <option value = 5>在执行环境下运行Python代码(exec操作)</option>
                         <option value = 6>在执行环境下获得Python表达式值(eval操作)</option>
+                        <option value = 7>暂停程序执行(如检测到验证码框出现时暂停执行)</option>
                     </select>
-
-                    <div v-if='nowNode["parameters"]["codeMode"] < 3 || nowNode["parameters"]["codeMode"] >= 5'>
+                    <div v-if='nowNode["parameters"]["codeMode"] == 7'>
+                        <label>此操作可以暂停程序执行,如检测到验证码框出现时暂停执行,直到手动长按键盘p键后才继续执行。</label>
+                    </div>
+                    <div v-if='nowNode["parameters"]["codeMode"] < 3 || nowNode["parameters"]["codeMode"] >= 5 && nowNode["parameters"]["codeMode"] <=6'>
                         <label>代码/脚本内容(用Field["字段名"]来输入某字段/自定义操作的最新提取/返回值): </label>
                         <textarea onkeydown="inputDelete(event)" class="form-control" rows="2" v-model='nowNode["parameters"]["code"]' placeholder="输入JS或系统命令,如:document.body.innerText = '1' 或 python D:/test.py,分别为JS命令和系统命令示例。如选择针对当前循环项的JS脚本,则循环项元素用arguments[0]表示,如arguments[0].style.color = 'blue'"></textarea>
                         <pre class="form-control" style="background: white; margin-top: 20px; min-height: 200px; font-size: 15px!important; word-wrap: break-word; white-space: pre-wrap; border-radius: 0; border: 1px solid" disabled v-if='nowNode["parameters"]["codeMode"] == 5'>请先阅读此说明,再在上方输入框(不是本框)写具体代码。

Plik diff jest za duży
+ 0 - 0
ElectronJS/tasks/208.json


Plik diff jest za duży
+ 0 - 0
ElectronJS/tasks/209.json


Plik diff jest za duży
+ 0 - 0
ElectronJS/tasks/210.json


Plik diff jest za duży
+ 0 - 0
ElectronJS/tasks/211.json


+ 1 - 1
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", "[73]", "--headless", "1", "--user_data", "0", "--keyboard", "0"]
+            "args": ["--id", "[81]", "--headless", "0", "--user_data", "0", "--keyboard", "1"]
         }
     ]
 }

+ 12 - 2
ExecuteStage/easyspider_executestage.py

@@ -116,6 +116,11 @@ class BrowserThread(Thread):
         self.browser.execute_cdp_cmd('Page.addScriptToEvaluateOnNewDocument', {
                                      'source': js})  # TMALL 反扒
         WebDriverWait(self.browser, 10)
+        self.browser.command_executor._commands["send_command"] = ("POST", '/session/$sessionId/chromium/send_command')
+        path = os.path.join(os.path.abspath("./"), "Data", "Task_" + str(self.id))
+        self.paramss = {'cmd': 'Page.setDownloadBehavior', 'params': {'behavior': 'allow', 'downloadPath': path}}
+
+        self.browser.execute("send_command", self.paramss) # 下载地址改变
         # self.browser.get('about:blank')
         self.procedure = service["graph"]  # 程序执行流程
         try:
@@ -619,6 +624,9 @@ class BrowserThread(Thread):
         elif codeMode == 4:
             self.CONTINUE = True
             self.recordLog("跳过本次循环|Skip this loop")
+        elif codeMode == 7: # 暂停程序执行
+            self.event.clear()
+            self.print_and_log("任务已暂停,长按p键继续执行...|Task paused, long press 'p' to continue...")
         else:  # 0 1 5 6
             output = self.execute_code(
                 codeMode, code, max_wait_time, iframe=paras["iframe"])
@@ -1948,9 +1956,11 @@ if __name__ == '__main__':
         if cloudflare == 0:
             options.add_argument('log-level=3')  # 隐藏日志
             option.add_argument('log-level=3')  # 隐藏日志
+            path = os.path.join(os.path.abspath("./"), "Data", "Task_" + str(i))
+            print("Data path:", path)
             options.add_experimental_option("prefs", {
                 # 设置文件下载路径
-                "download.default_directory": "Data/Task_" + str(i),
+                "download.default_directory": path,
                 "download.prompt_for_download": False,  # 禁止下载提示框
                 "plugins.plugins_list": [{"enabled": False, "name": "Chrome PDF Viewer"}],
                 "download.directory_upgrade": True,
@@ -1963,7 +1973,7 @@ if __name__ == '__main__':
             })
             option.add_experimental_option("prefs", {
                 # 设置文件下载路径
-                "download.default_directory": "Data/Task_" + str(i),
+                "download.default_directory": path,
                 "download.prompt_for_download": False,  # 禁止下载提示框
                 "plugins.plugins_list": [{"enabled": False, "name": "Chrome PDF Viewer"}],
                 "download.directory_upgrade": True,

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików