mirror of
https://github.com/NaiboWang/EasySpider.git
synced 2025-04-19 18:59:52 +08:00
New click way
This commit is contained in:
parent
a07630d5fa
commit
04442a13fe
@ -1 +1 @@
|
||||
{"webserver_address":"http://localhost","webserver_port":8074,"user_data_folder":"./user_data","absolute_user_data_folder":"D:\\Documents\\Projects\\EasySpider\\Releases\\EasySpider_windows_amd64\\user_data2"}
|
||||
{"webserver_address":"http://localhost","webserver_port":8074,"user_data_folder":"./user_data","absolute_user_data_folder":"D:\\Documents\\Projects\\EasySpider\\.temp_to_pub\\EasySpider_windows_x64\\user_data"}
|
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
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
File diff suppressed because one or more lines are too long
1
.temp_to_pub/EasySpider_windows_x64/tasks/46.json
Normal file
1
.temp_to_pub/EasySpider_windows_x64/tasks/46.json
Normal file
File diff suppressed because one or more lines are too long
Binary file not shown.
Binary file not shown.
@ -1 +1 @@
|
||||
{"webserver_address":"http://localhost","webserver_port":8074,"user_data_folder":"./user_data","absolute_user_data_folder":"/home/naibo/Documents/EasySpider/ElectronJS/user_data"}
|
||||
{"webserver_address":"http://localhost","webserver_port":8074,"user_data_folder":"./user_data","absolute_user_data_folder":"D:\\Documents\\Projects\\EasySpider\\ElectronJS\\user_data"}
|
@ -186,10 +186,35 @@ async function beginInvoke(msg, ws) {
|
||||
let message = JSON.parse(msg.message.pipe);
|
||||
let type = message.type;
|
||||
console.log("FROM Browser: ", message);
|
||||
// if(type.indexOf("Click")>=0){
|
||||
// await new Promise(resolve => setTimeout(resolve, 2000)); //等两秒
|
||||
//
|
||||
// }
|
||||
if(type.indexOf("Click")>=0){
|
||||
let handles = await driver.getAllWindowHandles();
|
||||
console.log("handles", handles);
|
||||
let exit = false;
|
||||
let content_handle = handle_pairs[message.id];
|
||||
console.log(message.id, content_handle);
|
||||
let order = [...handles.filter(handle => handle != current_handle && handle != content_handle), current_handle, content_handle]; //搜索顺序
|
||||
let len = order.length;
|
||||
while(true) {
|
||||
try{
|
||||
let h = order[len - 1];
|
||||
console.log("current_handle", current_handle);
|
||||
if(h != null && handles.includes(h)){
|
||||
await driver.switchTo().window(h);
|
||||
current_handle = h;
|
||||
console.log("switch to handle: ", h);
|
||||
}
|
||||
let element = await driver.findElement(By.xpath(message.xpath));
|
||||
await element.click();
|
||||
break;
|
||||
} catch (error) {
|
||||
console.log("len", len);
|
||||
len = len - 1;
|
||||
if (len == 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
socket_window.send(msg.message.pipe);
|
||||
console.log("FROM Flowchart: ", JSON.parse(msg.message.pipe));
|
||||
|
@ -129,6 +129,11 @@
|
||||
</div>
|
||||
<label>Maximum wait time for page load after clicking (in seconds):</label>
|
||||
<input onkeydown="inputDelete(event)" class="form-control" v-model.number="nowNode['parameters']['maxWaitTime']" type="number" required></input>
|
||||
<label>Click Type:</label>
|
||||
<select v-model='nowNode["parameters"]["clickWay"]' class="form-control">
|
||||
<option :value = 0>Selenium</option>
|
||||
<option :value = 1>JavaScript</option>
|
||||
</select>
|
||||
<label>Whether to scroll down after clicking:</label>
|
||||
<select v-model='nowNode["parameters"]["scrollType"]' class="form-control">
|
||||
<option value = 0>No Scrolling</option>
|
||||
@ -194,7 +199,7 @@
|
||||
<label><strong>{{paras.parameters[paraIndex]["name"]}}</strong></label>
|
||||
<p v-if="nowNode['isInLoop']"><input onkeydown="inputDelete(event)" type="checkbox" v-model='paras.parameters[paraIndex]["relative"]'></input>Use relative XPath</p>
|
||||
<p>XPATH: <span style="font-size: 30px!important;" title="Relative XPATH writing: start with /, e.g. the loop item XPATH is /html/body/div[1], your input is /*[@id='tab-customer'], then the final addressed xpath is: /html/body/div[1]/*[@id='tab-customer']">☺</span></p>
|
||||
<textarea onkeydown="inputDelete(event)" class="form-control" rows="2" v-model='paras.parameters[paraIndex]["relativeXPath"]'></textarea>
|
||||
<textarea onkeydown="inputDelete(event)" class="form-control" rows="2" v-model='paras.parameters[paraIndex]["relativeXPath"]' placeholder="If you want to write the XPath relative to the current element in the loop, you can write as *../div[1] which matches the first div child element of the parent of the current element in the loop."></textarea>
|
||||
<p><button type="button" data-toggle="modal" data-target="#myModal_XPath" @click="changeXPaths(paras.parameters[paraIndex]['allXPaths'])" class="btn btn-primary" style="margin-top: 10px">Click here to view other equivalent XPath expressions</button></p>
|
||||
<p style="margin-top: 10px">
|
||||
<a class="btn btn-primary" data-toggle="collapse" href="#elementAdvanced" role="button" aria-expanded="false" aria-controls="collapseExample">
|
||||
|
@ -129,6 +129,11 @@
|
||||
</div>
|
||||
<label>点击后页面加载最长等待时间(秒):</label>
|
||||
<input onkeydown="inputDelete(event)" class="form-control" v-model.number="nowNode['parameters']['maxWaitTime']" type="number" required></input>
|
||||
<label>点击类型:</label>
|
||||
<select v-model='nowNode["parameters"]["clickWay"]' class="form-control">
|
||||
<option :value = 0>Selenium点击</option>
|
||||
<option :value = 1>JavaScript点击</option>
|
||||
</select>
|
||||
<label>点击后是否向下滚动页面:</label>
|
||||
<select v-model='nowNode["parameters"]["scrollType"]' class="form-control">
|
||||
<option value = 0>不滚动</option>
|
||||
@ -194,7 +199,7 @@
|
||||
<label><strong>{{paras.parameters[paraIndex]["name"]}}</strong></label>
|
||||
<p v-if="nowNode['isInLoop']"><input onkeydown="inputDelete(event)" type="checkbox" v-model='paras.parameters[paraIndex]["relative"]'></input>使用相对循环内的XPATH</p>
|
||||
<p>XPath: <span style="font-size: 30px!important;" title="相对XPATH写法:以/开头,如循环项XPATH为/html/body/div[1],您的输入为/*[@id='tab-customer'],则最终寻址的xpath为:/html/body/div[1]/*[@id='tab-customer']">☺</span></p>
|
||||
<textarea onkeydown="inputDelete(event)" class="form-control" rows="2" v-model='paras.parameters[paraIndex]["relativeXPath"]'></textarea>
|
||||
<textarea onkeydown="inputDelete(event)" class="form-control" rows="2" v-model='paras.parameters[paraIndex]["relativeXPath"]' placeholder="如果要写相对循环内的xpath,可以写如*../div[1]即匹配当前循环元素的父元素的第一个div子元素"></textarea>
|
||||
<p><button type="button" data-toggle="modal" data-target="#myModal_XPath" @click="changeXPaths(paras.parameters[paraIndex]['allXPaths'])" class="btn btn-primary" style="margin-top: 10px">点此查看其他等价的XPath</button></p>
|
||||
<p style="margin-top: 10px">
|
||||
<a class="btn btn-primary" data-toggle="collapse" href="#elementAdvanced" role="button" aria-expanded="false" aria-controls="collapseExample">
|
||||
|
@ -158,6 +158,7 @@ function addParameters(t) {
|
||||
t["parameters"]["scrollType"] = 0; //滚动类型,0不滚动,1向下滚动1屏,2滚动到底部
|
||||
t["parameters"]["scrollCount"] = 1; //滚动次数
|
||||
t["parameters"]["scrollWaitTime"] = 1; //滚动后等待时间
|
||||
t["parameters"]["clickWay"] = 0; //点击方式,0代表selenium点击,1代表js点击
|
||||
t["parameters"]["maxWaitTime"] = 10; //最长等待时间
|
||||
t["parameters"]["paras"] = []; //默认参数列表
|
||||
t["parameters"]["wait"] = 2; //点击后等待时间默认2s
|
||||
|
@ -158,6 +158,7 @@ function addParameters(t) {
|
||||
t["parameters"]["scrollType"] = 0; //滚动类型,0不滚动,1向下滚动1屏,2滚动到底部
|
||||
t["parameters"]["scrollCount"] = 1; //滚动次数
|
||||
t["parameters"]["scrollWaitTime"] = 1; //滚动后等待时间
|
||||
t["parameters"]["clickWay"] = 0; //点击方式,0代表selenium点击,1代表js点击
|
||||
t["parameters"]["maxWaitTime"] = 10; //最长等待时间
|
||||
t["parameters"]["paras"] = []; //默认参数列表
|
||||
t["parameters"]["wait"] = 2; //点击后等待时间默认2s
|
||||
|
1
ElectronJS/tasks/102.json
Normal file
1
ElectronJS/tasks/102.json
Normal file
@ -0,0 +1 @@
|
||||
{"id":102,"name":"京东全球版-专业的综合网上购物商城","url":"https://www.jd.com","links":"https://www.jd.com","create_time":"6/27/2023, 11:34:38 PM","version":"0.3.3","containJudge":false,"desc":"https://www.jd.com","inputParameters":[{"id":0,"name":"urlList_0","nodeId":1,"nodeName":"打开网页","value":"https://www.jd.com","desc":"要采集的网址列表,多行以\\n分开","type":"string","exampleValue":"https://www.jd.com"}],"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":"","wait":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,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"url":"https://www.jd.com","links":"https://www.jd.com","maxWaitTime":10,"scrollType":0,"scrollCount":1,"scrollWaitTime":1}},{"id":2,"index":2,"parentId":0,"type":1,"option":8,"title":"循环","sequence":[3],"isInLoop":false,"position":1,"parameters":{"history":4,"tabIndex":-1,"useLoop":false,"xpath":"/html/body/div[5]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div/a","wait":0,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"scrollType":0,"scrollCount":1,"scrollWaitTime":1,"loopType":1,"pathList":"","textList":"","code":"","waitTime":0,"exitCount":0,"historyWait":2,"breakMode":0,"breakCode":"","breakCodeWaitTime":0,"allXPaths":""}},{"id":3,"index":3,"parentId":2,"type":0,"option":2,"title":"点击元素","sequence":[],"isInLoop":true,"position":0,"parameters":{"history":4,"tabIndex":-1,"useLoop":true,"xpath":"/html/body/div[5]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div/a","wait":2,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"scrollType":0,"scrollCount":1,"scrollWaitTime":1,"clickWay":0,"maxWaitTime":10,"paras":[],"allXPaths":"","loopType":1}}]}
|
1
ElectronJS/tasks/103.json
Normal file
1
ElectronJS/tasks/103.json
Normal file
@ -0,0 +1 @@
|
||||
{"id":103,"name":"","url":"https://www.maersk.com.cn/instantPrice/","links":"https://www.maersk.com.cn/instantPrice/","create_time":"6/27/2023, 11:54:03 PM","version":"0.3.3","containJudge":false,"desc":"https://www.maersk.com.cn/instantPrice/","inputParameters":[{"id":0,"name":"urlList_0","nodeId":1,"nodeName":"打开网页","value":"https://www.maersk.com.cn/instantPrice/","desc":"要采集的网址列表,多行以\\n分开","type":"string","exampleValue":"https://www.maersk.com.cn/instantPrice/"},{"id":1,"name":"inputText_1","nodeName":"输入文字","nodeId":2,"desc":"要输入的文本,如京东搜索框输入:电脑","type":"string","exampleValue":"Shang","value":"Shang"}],"outputParameters":[],"graph":[{"index":0,"id":0,"parentId":0,"type":-1,"option":0,"title":"root","sequence":[1,2,4],"parameters":{"history":1,"tabIndex":0,"useLoop":false,"xpath":"","wait":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,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"url":"https://www.maersk.com.cn/instantPrice/","links":"https://www.maersk.com.cn/instantPrice/","maxWaitTime":10,"scrollType":0,"scrollCount":1,"scrollWaitTime":1}},{"id":2,"index":2,"parentId":0,"type":0,"option":4,"title":"输入文字","sequence":[],"isInLoop":false,"position":1,"parameters":{"history":8,"tabIndex":-1,"useLoop":false,"xpath":"//*[contains(@class, \"searchFormOrigin\")]/div[1]/div[1]/div[1]/div[1]/div[1]/input[1]","wait":7,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"value":"Shang","allXPaths":["/html/body/div[2]/main[1]/div[1]/article[1]/section[1]/section[1]/section[1]/div[1]/form[1]/fieldset[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/input[1]","//input[contains(., '')]","//INPUT[@class='form-input__field']","/html/body/div[last()-4]/main/div/article/section/section/section/div/form/fieldset[last()-3]/div/div/div[last()-1]/div[last()-2]/div/div/div/div/div/input"]}},{"id":-1,"index":3,"parentId":0,"type":0,"option":2,"title":"点击元素","sequence":[],"isInLoop":false,"position":2,"parameters":{"history":8,"tabIndex":-1,"useLoop":false,"xpath":"//li[contains(., 'Shang Li (')]","wait":2,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"scrollType":0,"scrollCount":1,"scrollWaitTime":100,"clickWay":0,"maxWaitTime":10,"paras":[],"allXPaths":["/html/body/div[2]/main[1]/div[1]/article[1]/section[1]/section[1]/section[1]/div[1]/form[1]/fieldset[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div[2]/div[1]/ul[1]/li[2]","//li[contains(., 'Shang Li (')]","//LI[@class='typeahead__suggestions__link typeahead__suggestions__link--history']","/html/body/div[last()-4]/main/div/article/section/section/section/div/form/fieldset[last()-3]/div/div/div[last()-1]/div[last()-2]/div/div/div/div/div/div/ul/li[last()-14]"]}},{"id":3,"index":4,"parentId":0,"type":0,"option":2,"title":"点击元素","sequence":[],"isInLoop":false,"position":2,"parameters":{"history":3,"tabIndex":-1,"useLoop":false,"xpath":"//*[contains(@class, \"typeahead__suggestions__wrapper\")]/ul[1]/li[3]","wait":2,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"scrollType":0,"scrollCount":1,"scrollWaitTime":1,"clickWay":0,"maxWaitTime":10,"paras":[],"allXPaths":["/html/body/div[2]/main[1]/div[1]/article[1]/section[1]/section[1]/section[1]/div[1]/form[1]/fieldset[1]/div[2]/div[1]/div[1]/div[1]/div[1]/div[1]/div[2]/div[1]/div[2]/div[1]/ul[1]/li[3]","//li[contains(., 'Shanghai (')]","//LI[@class='typeahead__suggestions__link typeahead__suggestions__link--history']","/html/body/div[last()-4]/main/div/article/section/section/section/div/form/fieldset[last()-3]/div/div/div[last()-1]/div[last()-2]/div/div/div/div/div/div/ul/li[last()-13]"]}}]}
|
1
ElectronJS/tasks/104.json
Normal file
1
ElectronJS/tasks/104.json
Normal file
@ -0,0 +1 @@
|
||||
{"id":104,"name":"京东全球版-专业的综合网上购物商城","url":"https://www.jd.com","links":"https://www.jd.com","create_time":"6/28/2023, 12:13:15 AM","version":"0.3.3","containJudge":false,"desc":"https://www.jd.com","inputParameters":[{"id":0,"name":"urlList_0","nodeId":1,"nodeName":"打开网页","value":"https://www.jd.com","desc":"要采集的网址列表,多行以\\n分开","type":"string","exampleValue":"https://www.jd.com"}],"outputParameters":[{"id":0,"name":"自定义参数_0","desc":"","type":"string","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":"","wait":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,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"url":"https://www.jd.com","links":"https://www.jd.com","maxWaitTime":10,"scrollType":0,"scrollCount":1,"scrollWaitTime":1}},{"id":2,"index":2,"parentId":0,"type":1,"option":8,"title":"循环","sequence":[4,3],"isInLoop":false,"position":1,"parameters":{"history":4,"tabIndex":-1,"useLoop":false,"xpath":"/html/body/div[5]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div/a","wait":0,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"scrollType":0,"scrollCount":1,"scrollWaitTime":1,"loopType":1,"pathList":"","textList":"","code":"","waitTime":0,"exitCount":0,"historyWait":2,"breakMode":0,"breakCode":"","breakCodeWaitTime":0,"allXPaths":""}},{"id":4,"index":3,"parentId":2,"type":0,"option":2,"title":"点击元素","sequence":[],"isInLoop":true,"position":1,"parameters":{"history":4,"tabIndex":-1,"useLoop":true,"xpath":"/html/body/div[5]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div[1]/div/a","wait":2,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"scrollType":0,"scrollCount":1,"scrollWaitTime":1,"clickWay":0,"maxWaitTime":10,"paras":[],"allXPaths":"","loopType":1}},{"id":3,"index":4,"parentId":2,"type":0,"option":3,"title":"提取数据","sequence":[],"isInLoop":true,"position":0,"parameters":{"history":1,"tabIndex":0,"useLoop":false,"xpath":"","wait":0,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"paras":[{"nodeType":0,"contentType":0,"relative":true,"name":"自定义参数_0","desc":"","extractType":0,"relativeXPath":"*../../div[1]","allXPaths":[],"exampleValues":[{"num":0,"value":"自定义字段"}],"default":"","beforeJS":"","beforeJSWaitTime":0,"JS":"","JSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"downloadPic":0}]}}]}
|
1
ElectronJS/tasks/105.json
Normal file
1
ElectronJS/tasks/105.json
Normal file
@ -0,0 +1 @@
|
||||
{"id":105,"name":"百度一下,你就知道","url":"https://www.baidu.com","links":"https://www.baidu.com","create_time":"6/28/2023, 12:22:26 AM","version":"0.3.3","containJudge":false,"desc":"https://www.baidu.com","inputParameters":[{"id":0,"name":"urlList_0","nodeId":1,"nodeName":"打开网页","value":"https://www.baidu.com","desc":"要采集的网址列表,多行以\\n分开","type":"string","exampleValue":"https://www.baidu.com"}],"outputParameters":[{"id":0,"name":"自定义参数_0","desc":"","type":"string","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":"","wait":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,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"url":"https://www.baidu.com","links":"https://www.baidu.com","maxWaitTime":10,"scrollType":0,"scrollCount":1,"scrollWaitTime":1}},{"id":2,"index":2,"parentId":0,"type":1,"option":8,"title":"循环","sequence":[4,3],"isInLoop":false,"position":1,"parameters":{"history":4,"tabIndex":-1,"useLoop":false,"xpath":"/html/body/div[1]/div[1]/div[5]/div[1]/div[1]/div[3]/ul[1]/li/a[1]","wait":0,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"scrollType":0,"scrollCount":1,"scrollWaitTime":1,"loopType":1,"pathList":"","textList":"","code":"","waitTime":0,"exitCount":0,"historyWait":2,"breakMode":0,"breakCode":"","breakCodeWaitTime":0,"allXPaths":""}},{"id":4,"index":3,"parentId":2,"type":0,"option":2,"title":"点击元素","sequence":[],"isInLoop":true,"position":1,"parameters":{"history":4,"tabIndex":-1,"useLoop":true,"xpath":"/html/body/div[1]/div[1]/div[5]/div[1]/div[1]/div[3]/ul[1]/li/a[1]","wait":2,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"scrollType":0,"scrollCount":1,"scrollWaitTime":1,"clickWay":0,"maxWaitTime":10,"paras":[],"allXPaths":"","loopType":1}},{"id":3,"index":4,"parentId":2,"type":0,"option":3,"title":"提取数据","sequence":[],"isInLoop":true,"position":0,"parameters":{"history":1,"tabIndex":0,"useLoop":false,"xpath":"","wait":0,"beforeJS":"","beforeJSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"paras":[{"nodeType":0,"contentType":0,"relative":true,"name":"自定义参数_0","desc":"","extractType":0,"relativeXPath":"*../a/span[2]","allXPaths":[],"exampleValues":[{"num":0,"value":"自定义字段"}],"default":"","beforeJS":"","beforeJSWaitTime":0,"JS":"","JSWaitTime":0,"afterJS":"","afterJSWaitTime":0,"downloadPic":0}]}}]}
|
2
ExecuteStage/.vscode/launch.json
vendored
2
ExecuteStage/.vscode/launch.json
vendored
@ -12,7 +12,7 @@
|
||||
"console": "integratedTerminal",
|
||||
"justMyCode": true,
|
||||
// "args": ["--id", "38", "--read_type", "local", "--headless", "1"]
|
||||
"args": ["--id", "[2]", "--headless", "0", "--user_data", "0"]
|
||||
"args": ["--id", "[99]", "--headless", "0", "--user_data", "1"]
|
||||
}
|
||||
]
|
||||
}
|
@ -2,5 +2,5 @@
|
||||
"webserver_address": "http://localhost",
|
||||
"webserver_port": 8074,
|
||||
"user_data_folder": "./user_data",
|
||||
"absolute_user_data_folder": "D:\\Documents\\Projects\\EasySpider\\ElectronJS\\user_data"
|
||||
"absolute_user_data_folder": "D:\\Documents\\Projects\\EasySpider\\.temp_to_pub\\EasySpider_windows_x64\\user_data"
|
||||
}
|
@ -760,6 +760,14 @@ class BrowserThread(Thread):
|
||||
path + ", please try to set the wait time before executing this operation")
|
||||
tempHandleNum = len(self.browser.window_handles) # 记录之前的窗口位置
|
||||
try:
|
||||
click_way = int(para["clickWay"])
|
||||
except:
|
||||
click_way = 0
|
||||
try:
|
||||
if click_way == 0: # 用selenium的点击方法
|
||||
actions = ActionChains(self.browser) # 实例化一个action对象
|
||||
actions.click(element).perform()
|
||||
elif click_way == 1: # 用js的点击方法
|
||||
script = 'var result = document.evaluate(`' + path + \
|
||||
'`, document, null, XPathResult.ANY_TYPE, null);for(let i=0;i<arguments[0];i++){result.iterateNext();} result.iterateNext().click();'
|
||||
self.browser.execute_script(script, str(index)) # 用js的点击方法
|
||||
@ -936,7 +944,7 @@ class BrowserThread(Thread):
|
||||
p["relativeXPath"][1:])
|
||||
else:
|
||||
element = self.browser.find_element(By.XPATH, p["relativeXPath"])
|
||||
except (NoSuchElementException, InvalidSelectorException): # 找不到元素的时候,使用默认值
|
||||
except (NoSuchElementException, InvalidSelectorException, StaleElementReferenceException): # 找不到元素的时候,使用默认值
|
||||
# print(p)
|
||||
try:
|
||||
content = p["default"]
|
||||
|
@ -57,6 +57,7 @@ export function input(value) {
|
||||
export function sendSingleClick() {
|
||||
let message = {
|
||||
"type": "singleClick",
|
||||
"id": global.id,
|
||||
"history": history.length, //记录history的长度
|
||||
"tabIndex": -1,
|
||||
"useLoop": false, //是否使用循环内元素
|
||||
@ -208,6 +209,7 @@ export function collectMultiWithPattern() {
|
||||
export function sendLoopClickSingle(name) {
|
||||
let message = {
|
||||
"type": "loopClickSingle",
|
||||
"id": global.id,
|
||||
"history": history.length, //记录history的长度
|
||||
"tabIndex": -1,
|
||||
"useLoop": true, //是否使用循环内元素
|
||||
@ -231,6 +233,7 @@ export function sendLoopClickSingle(name) {
|
||||
export function sendLoopClickEvery() {
|
||||
let message = {
|
||||
"type": "loopClickEvery",
|
||||
"id": global.id,
|
||||
"history": history.length, //记录history的长度
|
||||
"tabIndex": -1,
|
||||
"xpath": "", //默认值设置为空
|
||||
|
@ -465,11 +465,12 @@ export default {
|
||||
}
|
||||
}
|
||||
},
|
||||
clickElement: function () { //点击元素操作
|
||||
clickElement: async function () { //点击元素操作
|
||||
sendSingleClick();
|
||||
//先发送数据
|
||||
global.nodeList[0]["node"].focus(); //获得元素焦点
|
||||
global.nodeList[0]["node"].click(); //点击元素
|
||||
await new Promise(resolve => setTimeout(resolve, 500)); //因为nodejs点击后又会把当前元素加入到列表中,所以这里需要等待一下再清空
|
||||
// global.nodeList[0]["node"].click(); //点击元素
|
||||
clearEl();
|
||||
},
|
||||
changeSelect: function(){
|
||||
@ -527,18 +528,20 @@ export default {
|
||||
sendLoopMouseMove();
|
||||
clearEl();
|
||||
},
|
||||
loopClickSingleElement: function () { //循环点击单个元素
|
||||
loopClickSingleElement: async function () { //循环点击单个元素
|
||||
sendLoopClickSingle(this.tname()); //识别下一页,循环点击单个元素和点击多个元素
|
||||
// if (this.tname() != "下一页元素") { //下一页元素不进行点击操作
|
||||
global.nodeList[0]["node"].focus(); //获得元素焦点
|
||||
global.nodeList[0]["node"].click(); //点击元素
|
||||
await new Promise(resolve => setTimeout(resolve, 500)); //因为nodejs点击后又会把当前元素加入到列表中,所以这里需要等待一下再清空
|
||||
// global.nodeList[0]["node"].click(); //点击元素
|
||||
// }
|
||||
clearEl();
|
||||
},
|
||||
loopClickEveryElement: function () { //循环点击每个元素
|
||||
loopClickEveryElement: async function () { //循环点击每个元素
|
||||
sendLoopClickEvery(); //识别下一页,循环点击单个元素和点击多个元素
|
||||
global.nodeList[0]["node"].focus(); //获得元素焦点
|
||||
global.nodeList[0]["node"].click(); //点击元素
|
||||
await new Promise(resolve => setTimeout(resolve, 500)); //因为nodejs点击后又会把当前元素加入到列表中,所以这里需要等待一下再清空
|
||||
// global.nodeList[0]["node"].click(); //点击元素
|
||||
clearEl();
|
||||
},
|
||||
setInput: function () { //输入文字
|
||||
|
Loading…
x
Reference in New Issue
Block a user