diff --git a/ElectronJS/.gitignore b/ElectronJS/.gitignore index 2e1be61..706816f 100644 --- a/ElectronJS/.gitignore +++ b/ElectronJS/.gitignore @@ -8,4 +8,5 @@ chromedriver_mac64 user-data/ user_data/ Data/ +Chrome/ execution_instances/* diff --git a/ElectronJS/EasySpider_en.crx b/ElectronJS/EasySpider_en.crx index 83fbf8f..1a91478 100644 Binary files a/ElectronJS/EasySpider_en.crx and b/ElectronJS/EasySpider_en.crx differ diff --git a/ElectronJS/EasySpider_zh.crx b/ElectronJS/EasySpider_zh.crx index 553def8..4f888b6 100644 Binary files a/ElectronJS/EasySpider_zh.crx and b/ElectronJS/EasySpider_zh.crx differ diff --git a/ElectronJS/XPathHelper.crx b/ElectronJS/XPathHelper.crx new file mode 100644 index 0000000..d24c7a2 Binary files /dev/null and b/ElectronJS/XPathHelper.crx differ diff --git a/ElectronJS/check_update.js b/ElectronJS/check_update.js new file mode 100644 index 0000000..a04b26a --- /dev/null +++ b/ElectronJS/check_update.js @@ -0,0 +1,34 @@ +const https = require('https'); +const fs = require("fs"); +const path = require("path"); + +// 设置GitHub用户名和仓库名 +const owner = 'NaiboWang'; +const repo = 'EasySpider'; +let config = fs.readFileSync(path.join(__dirname, `package.json`), 'utf8'); +config = JSON.parse(config); +const version = config.version; +console.log(`Current version is ${version}`); + +// 发送GET请求获取GitHub的Release API响应 +https.get(`https://api.github.com/repos/${owner}/${repo}/releases/latest`, { + headers: { + 'User-Agent': 'Node.js' + } +}, (res) => { + let data = ''; + res.on('data', (chunk) => { + data += chunk; + }); + res.on('end', () => { + // 解析响应JSON并输出最新版本号 + const release = JSON.parse(data); + const latestVersion = release.tag_name.replace('v', ''); + console.log(`Latest version is ${latestVersion}`); + if(version !== latestVersion) { + console.log('There is a new version of EasySpider, you can download it from github repo: https://github.com/NaiboWang/EasySpider/releases'); + } + }); +}).on('error', (err) => { + console.error(`Error: ${err.message}`); +}); \ No newline at end of file diff --git a/ElectronJS/config.json b/ElectronJS/config.json index 78a2110..d7f6cab 100644 --- a/ElectronJS/config.json +++ b/ElectronJS/config.json @@ -1 +1 @@ -{"webserver_address":"http://localhost","webserver_port":8074,"user_data_folder":"./user_data","absolute_user_data_folder":"/Users/naibowang/Documents/EasySpider/ElectronJS/user_data"} \ No newline at end of file +{"webserver_address":"http://localhost","webserver_port":8074,"user_data_folder":"./user_data","absolute_user_data_folder":"D:\\Documents\\Projects\\EasySpider\\ElectronJS\\user_data"} \ No newline at end of file diff --git a/ElectronJS/main.js b/ElectronJS/main.js index 7507271..bd58c26 100644 --- a/ElectronJS/main.js +++ b/ElectronJS/main.js @@ -1,7 +1,6 @@ // Modules to control application life and create native browser window const {app, BrowserWindow, dialog, ipcMain, screen} = require('electron'); app.commandLine.appendSwitch("--disable-http-cache"); - const {Builder, By, Key, until} = require("selenium-webdriver"); const chrome = require('selenium-webdriver/chrome'); const {ServiceBuilder} = require('selenium-webdriver/chrome'); @@ -123,6 +122,7 @@ async function beginInvoke(msg, ws) { } flowchart_window.show(); + // flowchart_window.openDevTools(); } else if (msg.type == 2) { //keyboard // const robot = require("@jitsi/robotjs"); @@ -215,13 +215,13 @@ async function beginInvoke(msg, ws) { // }); let spawn = require("child_process").spawn; - if (process.platform != "darwin") { + if (process.platform != "darwin" && msg.message.execute_type == 1) { let child_process = spawn(execute_path, parameters); child_process.stdout.on('data', function (data) { console.log(data.toString()); }); } else { - ws.send(task_server.getDir() + "/"); + ws.send(JSON.stringify({"config_folder": task_server.getDir() + "/", "easyspider_location": task_server.getEasySpiderLocation()})); } } } @@ -284,6 +284,7 @@ async function runBrowser(lang = "en", user_data_folder = '') { } else if (lang == "zh") { options.addExtensions(path.join(__dirname, "EasySpider_zh.crx")); } + options.addExtensions(path.join(__dirname, "XPathHelper.crx")); options.setChromeBinaryPath(chromeBinaryPath); if (user_data_folder != "") { let dir = path.join(task_server.getDir(), user_data_folder); diff --git a/ElectronJS/package.json b/ElectronJS/package.json index 3cedaed..b4acc20 100644 --- a/ElectronJS/package.json +++ b/ElectronJS/package.json @@ -1,7 +1,7 @@ { "name": "easy-spider", "productName": "EasySpider", - "version": "0.2.0", + "version": "0.3.0", "icon": "./favicon", "description": "NoCode Visual Web Crawler", "main": "main.js", @@ -60,7 +60,7 @@ ], "packagerConfig": { "icon": "./favicon", - "appVersion": "0.2.0", + "appVersion": "0.3.0", "name": "EasySpider", "executableName": "EasySpider", "appCopyright": "Naibo Wang (naibowang@foxmail.com)", diff --git a/ElectronJS/server.js b/ElectronJS/server.js index 9a6719d..fe0e681 100644 --- a/ElectronJS/server.js +++ b/ElectronJS/server.js @@ -29,7 +29,18 @@ function getDir(){ } else { return path.join(__dirname,"../../.."); } - } else{ + } else { + return __dirname; + } +} +function getEasySpiderLocation(){ + if(__dirname.indexOf("app") >= 0 && __dirname.indexOf("sources") >= 0){ + if(process.platform == "darwin"){ + return path.join(__dirname,"../../../"); + } else { + return path.join(__dirname,"../../../"); + } + } else { return __dirname; } } @@ -44,6 +55,7 @@ if(!fs.existsSync(path.join(getDir(), "config.json"))){ } exports.getDir = getDir; +exports.getEasySpiderLocation = getEasySpiderLocation; FileMimes = JSON.parse(fs.readFileSync(path.join(__dirname,'mime.json')).toString()); exports.start = function(port = 8074) { http.createServer(function(req, res) { diff --git a/ElectronJS/src/img/XPather_helper.png b/ElectronJS/src/img/XPather_helper.png new file mode 100644 index 0000000..002ee82 Binary files /dev/null and b/ElectronJS/src/img/XPather_helper.png differ diff --git a/ElectronJS/src/index.html b/ElectronJS/src/index.html index f6b56d0..89b48e8 100644 --- a/ElectronJS/src/index.html +++ b/ElectronJS/src/index.html @@ -24,6 +24,10 @@
+Github最新版本/Newest Version:{{newest_version}}
+ + +Use relative XPATH
- +