Skip to content

Commit

Permalink
增加调用第三方包的说明
Browse files Browse the repository at this point in the history
  • Loading branch information
naibo committed Jul 20, 2023
1 parent f8c575f commit 0d7e0cb
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 3 deletions.
12 changes: 11 additions & 1 deletion ElectronJS/src/taskGrid/FlowChart.html
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,17 @@ <h4 class="modal-title">Equivalent XPath</h4>
2. Define a global variable: `self.myVar = 1`
3. Manipulate the above-defined global variable: `self.myVar = self.myVar + 1`
4. Print the above-defined global variable: `print(self.myVar)`
If you want to record your custom variable as a field, please select the next option, "Evaluate Python expressions in the execution environment."</pre>

If you want to record your custom variable as a field, please select the next option, "Evaluate Python expressions in the execution environment."

If you want to import and use a third-party library that the program itself does not carry, you need to first use tools such as pip to install this library locally, and then add the path of the installed library before import, like:
(1) In the system command line execute the following command to install the library:
pip install emotlib
(2) Write the following code in the code box:
sys.path.append("D:/Python38/Lib/site-packages") # Assume emotlib library exists in this path
import emotlib # Now you can use emotlib library
print(emotlib.emoji()) # Use one of its functions.
</pre>
<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"] == 6'>Please read the instructions first and then write the specific code in the input box above (not in this box).
This option is an advanced feature that allows directly returning the expression value of Python code, and in other places, use Field["FieldName"] to represent the return value of this operation.. Here are some examples:
1. Return relevant values of the current browser object. Use `self.browser` to refer to the current browser being operated. You can directly use Selenium's API to perform operations, such as `self.browser.find_element(By.CSS_SELECTOR, "body").text` to return the text on the current page.
Expand Down
12 changes: 11 additions & 1 deletion ElectronJS/src/taskGrid/FlowChart_CN.html
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,17 @@ <h4 class="modal-title">等价XPath</h4>
2. 自定义一个全局变量:self.myVar = 1
3. 操纵上面定义的全局变量:self.myVar = self.myVar + 1
4. 打印上面定义的全局变量:print(self.myVar)
如果想要将自己定义的变量作为字段记录,请选择下一个“在执行环境下获得Python表达式值(eval操作)”选项。</pre>

如果想要将自己定义的变量作为字段记录,请选择下一个“在执行环境下获得Python表达式值(eval操作)”选项。

5. 如果想要引入并使用程序本身没有带的第三方库,需要先使用如pip等工具本地安装好此库,然后在import之前添加自己安装的库的路径,如:
(1)在系统命令行执行安装emotlib库命令:
pip install emotlib
(2)在代码框中写入如下代码:
sys.path.append("D:/Python38/Lib/site-packages") # 假设此路径下有emotlib库
import emotlib # 此时就可以使用emotlib库了
print(emotlib.emoji()) # 使用其中的函数。
</pre>
<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"] == 6'>请先阅读此说明,再在上方输入框(不是本框)写具体代码。
此选项为高级功能,可以直接返回Python代码的表达式值,并在其他位置用Field["本操作名称"]表示此操作返回值,示例:
1. 返回当前浏览器对象的相关值,用self.browser表示当前操作的浏览器,可直接用selenium的API进行操作,如self.browser.find_element(By.CSS_SELECTOR, "body").text即可返回当前页面的文字。
Expand Down
1 change: 1 addition & 0 deletions ElectronJS/tasks/193.json
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"id":193,"name":"TEST PYTHON LIBRARY","url":"https://www.jd.com","links":"https://www.jd.com","create_time":"","update_time":"7/20/2023, 2:58:44 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.jd.com","inputParameters":[{"id":0,"name":"urlList_0","nodeId":1,"nodeName":"打开网页","value":"https://www.jd.com","desc":"要采集的网址列表,多行以\\n分开","type":"text","exampleValue":"https://www.jd.com"}],"outputParameters":[{"id":0,"name":"自定义操作","desc":"自定义操作返回的数据","type":"text","recordASField":0,"exampleValue":""}],"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":"https://www.jd.com","links":"https://www.jd.com","maxWaitTime":10,"scrollType":0,"scrollCount":1,"scrollWaitTime":1,"cookies":""}},{"id":2,"index":2,"parentId":0,"type":0,"option":5,"title":"自定义操作","sequence":[],"isInLoop":false,"position":1,"parameters":{"history":1,"tabIndex":0,"useLoop":false,"xpath":"","iframe":false,"wait":20,"waitType":0,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"waitElement":"","waitElementTime":10,"waitElementIframeIndex":0,"clear":0,"codeMode":"5","code":"sys.path.append('F:/')\nimport emotlib\nprint(emotlib.emoji())","waitTime":0,"recordASField":0,"paraType":"text"}}]}
2 changes: 1 addition & 1 deletion ExecuteStage/.vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -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", "[88]", "--headless", "0", "--user_data", "1", "--keyboard", "0"]
"args": ["--id", "[92]", "--headless", "0", "--user_data", "1", "--keyboard", "0"]
}
]
}

0 comments on commit 0d7e0cb

Please sign in to comment.