提取数据操作获得eval返回值

This commit is contained in:
naibo 2023-07-15 18:26:03 +08:00
parent a7462f758b
commit 1705418c87
7 changed files with 12 additions and 6 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -271,11 +271,12 @@
<option :value = 8>OCR Results</option>
<option :value = 9>Return value of JavaScript code (for this element), starting with 'return')</option>
<option :value = 12>System command return value</option>
<option :value = 13>Value of a Python expression (the "eval" operation)</option>
<option :value = 10>Selected value of the current select box</option>
<option :value = 11>Selected text of the current select box</option>
</select>
<div v-if='paras.parameters[paraIndex]["contentType"] == 9'>
<label>JavaScript Code (Use Field["FieldName"] to input the lastest value of a field): </label>
<div v-if='paras.parameters[paraIndex]["contentType"] == 9 || paras.parameters[paraIndex]["contentType"] >= 12'>
<label>Code (Use Field["FieldName"] to input the lastest value of a field): </label>
<textarea onkeydown="inputDelete(event)" class="form-control" rows="2"
placeholder='The element should be represented by arguments[0]. Here is an example: return arguments[0].innerText + "US Dollar". This code extracts the innerText of the element and appends "US Dollar" to it.' v-model='paras.parameters[paraIndex]["JS"]'></textarea>
<label>Maximum wait time for script execution (0 represents unlimited wait time): </label>

View File

@ -271,11 +271,12 @@
<option :value = 8>OCR识别文字</option>
<option :value = 9>针对该元素的JavaScript代码返回值需以return 开头)</option>
<option :value = 12>系统命令返回值</option>
<option :value = 13>执行环境下的Python表达式值eval操作</option>
<option :value = 10>当前选择框选中的选项值</option>
<option :value = 11>当前选择框选中的选项文本</option>
</select>
<div v-if='paras.parameters[paraIndex]["contentType"] == 9 || paras.parameters[paraIndex]["contentType"] == 12'>
<label>JavaScript代码也可以不针对该元素直接写return JS代码即可/系统命令代码:</label>
<div v-if='paras.parameters[paraIndex]["contentType"] == 9 || paras.parameters[paraIndex]["contentType"] >= 12'>
<label>JavaScript也可以不针对该元素直接写return JS代码即可/系统命令/Python代码:</label>
<textarea onkeydown="inputDelete(event)" class="form-control" rows="2"
placeholder='如要针对该元素则该元素用arguments[0]来表示示例return arguments[0].innerText + "美元"即实现了提取该元素innerText并后面加“美元”的功能不然直接如写return new Date().toString()即可获得当前时间戳。' v-model='paras.parameters[paraIndex]["JS"]'></textarea>
<label>最长等待脚本执行时间0代表无限等待 </label>

View File

@ -0,0 +1 @@
{"id":182,"name":"京东全球版-专业的综合网上购物商城","url":"https://www.jd.com","links":"https://www.jd.com","create_time":"7/15/2023, 6:23:53 PM","update_time":"7/15/2023, 6:25:18 PM","version":"0.3.6","saveThreshold":10,"cloudflare":0,"environment":0,"maxViewLength":15,"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":""},{"id":1,"name":"自定义参数_1","desc":"","type":"text","recordASField":1,"exampleValue":"自定义值"},{"id":2,"name":"自定义参数_2","desc":"","type":"text","recordASField":1,"exampleValue":"自定义值"}],"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":"","wait":0,"waitType":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,"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":0,"waitType":0,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"clear":0,"codeMode":"5","code":"self.a = 151515","waitTime":0,"recordASField":0,"paraType":"text"}},{"id":3,"index":3,"parentId":0,"type":0,"option":3,"title":"提取数据","sequence":[],"isInLoop":false,"position":2,"parameters":{"history":1,"tabIndex":0,"useLoop":false,"xpath":"","iframe":false,"wait":0,"waitType":0,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"clear":0,"paras":[{"nodeType":0,"contentType":13,"relative":false,"name":"自定义参数_1","desc":"","extractType":0,"relativeXPath":"//body","recordASField":1,"allXPaths":[],"exampleValues":[{"num":0,"value":"自定义值"}],"default":"","beforeJS":"","beforeJSWaitTime":0,"JS":"self.a","JSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"downloadPic":0,"paraType":"text"},{"nodeType":0,"contentType":13,"relative":false,"name":"自定义参数_2","desc":"","extractType":0,"relativeXPath":"//body","recordASField":1,"allXPaths":[],"exampleValues":[{"num":0,"value":"自定义值"}],"default":"","beforeJS":"","beforeJSWaitTime":0,"JS":"self.a + 10000","JSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"downloadPic":0,"paraType":"text"}]}}]}

View File

@ -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", "[9]", "--headless", "0", "--user_data", "1", "--keyboard", "0"]
"args": ["--id", "[84]", "--headless", "0", "--user_data", "1", "--keyboard", "0"]
}
]
}

View File

@ -1415,6 +1415,8 @@ class BrowserThread(Thread):
2, p["JS"], p["JSWaitTime"], element, iframe=p["iframe"])
elif p["contentType"] == 12: # 系统命令返回值
content = self.execute_code(1, p["JS"], p["JSWaitTime"])
elif p["contentType"] == 13: # eval返回值
content = self.execute_code(6, p["JS"], p["JSWaitTime"])
elif p["contentType"] == 10: # 下拉框选中的值
try:
select_element = Select(element)