MACOS version

This commit is contained in:
Naibo Wang 2023-03-28 23:10:36 +08:00
parent f54ebcd74a
commit 79d0144e77
24 changed files with 43 additions and 12 deletions

BIN
.DS_Store vendored

Binary file not shown.

BIN
ElectronJS/.DS_Store vendored

Binary file not shown.

View File

@ -94,7 +94,7 @@ function createWindow() {
} }
async function beginInvoke(msg) { async function beginInvoke(msg, ws) {
if (msg.type == 1) { if (msg.type == 1) {
if (msg.message.id != -1) { if (msg.message.id != -1) {
let url = ""; let url = "";
@ -220,6 +220,8 @@ async function beginInvoke(msg) {
child_process.stdout.on('data', function (data) { child_process.stdout.on('data', function (data) {
console.log(data.toString()); console.log(data.toString());
}); });
} else {
ws.send(task_server.getDir() + "/");
} }
} }
} }
@ -265,7 +267,7 @@ wss.on('connection', function (ws) {
} }
} }
else { else {
await beginInvoke(msg); await beginInvoke(msg, ws);
} }
}); });
}); });

View File

@ -3,12 +3,12 @@
# This script is used to build.md the package for Linux 64-bit. # This script is used to build.md the package for Linux 64-bit.
rm -rf out rm -rf out
rm -r ../Releases/EasySpider_MacOS_all_arch/EasySpider.app rm -r ../Releases/EasySpider_MacOS_all_arch/EasySpider.app
npm run package npm run make
# unzip out/EasySpider-darwin-x64 -d ../Releases/EasySpider_MacOS_all_arch/ unzip out/make/zip/darwin/x64/EasySpider-darwin-x64* -d ../Releases/EasySpider_MacOS_all_arch/
mv out/EasySpider-darwin-x64/EasySpider.app ../Releases/EasySpider_MacOS_all_arch/ # mv out/EasySpider-darwin-x64/EasySpider.app ../Releases/EasySpider_MacOS_all_arch/
rm ../Releases/EasySpider_MacOS_all_arch/EasySpider.app/Contents/Resources/app/VS_BuildTools.exe rm ../Releases/EasySpider_MacOS_all_arch/EasySpider.app/Contents/Resources/app/VS_BuildTools.exe
rm -r ../Releases/EasySpider_MacOS_all_arch/EasySpider.app/Contents/Resources/app/chrome_win64 rm -r ../Releases/EasySpider_MacOS_all_arch/EasySpider.app/Contents/Resources/app/chrome_win64
# rm -r ../Releases/EasySpider_MacOS_all_arch/EasySpider.app/Contents/Resources/app/Data rm -r ../Releases/EasySpider_MacOS_all_arch/EasySpider.app/Contents/Resources/app/Data
rm -r ../Releases/EasySpider_MacOS_all_arch/EasySpider.app/Contents/Resources/app/.idea rm -r ../Releases/EasySpider_MacOS_all_arch/EasySpider.app/Contents/Resources/app/.idea
# rm -r ../Releases/EasySpider_MacOS_all_arch/EasySpider.app/Contents/Resources/app/tasks # rm -r ../Releases/EasySpider_MacOS_all_arch/EasySpider.app/Contents/Resources/app/tasks
# rm -r ../Releases/EasySpider_MacOS_all_arch/EasySpider.app/Contents/Resources/app/execution_instances # rm -r ../Releases/EasySpider_MacOS_all_arch/EasySpider.app/Contents/Resources/app/execution_instances

View File

@ -3,6 +3,7 @@ const querystring = require('querystring');
const url = require('url'); const url = require('url');
const fs = require('fs'); const fs = require('fs');
const path=require('path'); const path=require('path');
const {app, dialog} = require('electron');
function travel(dir,callback){ function travel(dir,callback){
fs.readdirSync(dir).forEach((file)=>{ fs.readdirSync(dir).forEach((file)=>{
const pathname=path.join(dir,file) const pathname=path.join(dir,file)
@ -24,7 +25,7 @@ function compare(p){ //这是比较函数
function getDir(){ function getDir(){
if(__dirname.indexOf("app") >= 0 && __dirname.indexOf("sources") >= 0){ if(__dirname.indexOf("app") >= 0 && __dirname.indexOf("sources") >= 0){
if(process.platform == "darwin"){ if(process.platform == "darwin"){
return __dirname; return app.getPath("userData");
} else { } else {
return path.join(__dirname,"../../.."); return path.join(__dirname,"../../..");
} }
@ -32,6 +33,15 @@ function getDir(){
return __dirname; return __dirname;
} }
} }
if(!fs.existsSync(path.join(getDir(), "tasks"))){
fs.mkdirSync(path.join(getDir(), "tasks"));
}
if(!fs.existsSync(path.join(getDir(), "execution_instances"))){
fs.mkdirSync(path.join(getDir(), "execution_instances"));
}
if(!fs.existsSync(path.join(getDir(), "config.json"))){
fs.writeFileSync(path.join(getDir(), "config.json"), JSON.stringify({"webserver_address":"http://localhost","webserver_port":8074,"user_data_folder":"./user_data","absolute_user_data_folder":""}));
}
exports.getDir = getDir; exports.getDir = getDir;
FileMimes = JSON.parse(fs.readFileSync(path.join(__dirname,'mime.json')).toString()); FileMimes = JSON.parse(fs.readFileSync(path.join(__dirname,'mime.json')).toString());

View File

@ -50,7 +50,7 @@
<input onkeydown="inputDelete(event)" id="serviceId" type="hidden" name="serviceId" value="-1"></input> <input onkeydown="inputDelete(event)" id="serviceId" type="hidden" name="serviceId" value="-1"></input>
<input onkeydown="inputDelete(event)" id="url" type="hidden" name="url" value="about:blank"></input> <input onkeydown="inputDelete(event)" id="url" type="hidden" name="url" value="about:blank"></input>
<label>{{"For MacOS, please open a terminal, go to EasySpider's folder, and then type the following command to run the task (EasySpider cannot quit when executing command):~对于MacOS系统请在EasySpider目录下打开命令行工具Terminal然后复制和运行以下命令以执行任务(执行命令时不能退出EasySpider)" | lang}}</label> <label>{{"For MacOS, please open a terminal, go to EasySpider's folder, and then type the following command to run the task (EasySpider cannot quit when executing command):~对于MacOS系统请在EasySpider目录下打开命令行工具Terminal然后复制和运行以下命令以执行任务(执行命令时不能退出EasySpider)" | lang}}</label>
<textarea class="form-control">{{command}}</textarea> <textarea class="form-control" style="height:150px">{{command}} --config_folder "{{config_folder}}"</textarea>
</div> </div>
<!-- <div class="modal-footer"> <!-- <div class="modal-footer">
<button type="button" id="saveAsButton" class="btn btn-outline-primary">另存为</button> <button type="button" id="saveAsButton" class="btn btn-outline-primary">另存为</button>
@ -152,7 +152,8 @@
user_data_folder:"", user_data_folder:"",
with_user_data: true, with_user_data: true,
backEndAddressServiceWrapper: getUrlParam("backEndAddressServiceWrapper"), backEndAddressServiceWrapper: getUrlParam("backEndAddressServiceWrapper"),
command: "./easyspider_executestage " command: "./easyspider_executestage ",
config_folder: "",
}, mounted() { }, mounted() {
$.get(this.backEndAddressServiceWrapper + "/getConfig", function (result) { $.get(this.backEndAddressServiceWrapper + "/getConfig", function (result) {
app.$data.user_data_folder = result.user_data_folder; app.$data.user_data_folder = result.user_data_folder;
@ -287,6 +288,9 @@
}; };
this.send(JSON.stringify(message)); this.send(JSON.stringify(message));
}; };
ws.onmessage = function(message){
app.$data.config_folder = message.data;
}
ws.onclose = function () { ws.onclose = function () {
// 关闭 websocket // 关闭 websocket
console.log("连接已关闭..."); console.log("连接已关闭...");

View File

@ -683,6 +683,7 @@ if __name__ == '__main__':
"saved_file_name": "", "saved_file_name": "",
"read_type": "remote", "read_type": "remote",
"user_data": False, "user_data": False,
"config_folder": ""
} }
c = Config(config) c = Config(config)
print(c) print(c)
@ -759,7 +760,7 @@ if __name__ == '__main__':
# 3. 就算User Profile相同chrome版本不同所存储的cookie信息也不同也不能爬 # 3. 就算User Profile相同chrome版本不同所存储的cookie信息也不同也不能爬
# 4. TMALL如果一直弹出验证码而且无法通过验证那么需要在其他浏览器上用 # 4. TMALL如果一直弹出验证码而且无法通过验证那么需要在其他浏览器上用
if c.user_data: if c.user_data:
with open("config.json","r") as f: with open(c.config_folder + "config.json","r") as f:
config = json.load(f) config = json.load(f)
absolute_user_data_folder = config["absolute_user_data_folder"] absolute_user_data_folder = config["absolute_user_data_folder"]
print("\nAbsolute_user_data_folder:",absolute_user_data_folder,"\n") print("\nAbsolute_user_data_folder:",absolute_user_data_folder,"\n")

View File

@ -0,0 +1 @@
easyspider_executestage

View File

@ -0,0 +1 @@


View File

@ -0,0 +1 @@


View File

@ -0,0 +1 @@


View File

@ -0,0 +1 @@


View File

@ -0,0 +1 @@


View File

@ -0,0 +1,3 @@
openPage
Loading page: https://www.jd.com
Done!

View File

@ -0,0 +1 @@


View File

@ -0,0 +1 @@


View File

@ -0,0 +1,3 @@
openPage
Loading page: https://www.jd.com
Done!

View File

@ -2,7 +2,7 @@
文件访问权限必须给,麦克风权限完全用不到,作者也不清楚为什么会需要麦克风,因此可以拒绝。 文件访问权限必须给,麦克风权限完全用不到,作者也不清楚为什么会需要麦克风,因此可以拒绝。
可以从其他机器导入任务只需要打开此目录的EasySpider软件右键“显示包内容”然后把其他机器的tasks文件夹里的.json文件放入Contents/Resources/app/tasks文件夹里即可。同理执行号文件可以通过复制execution_instances文件夹中的.json文件来导入。注意两个文件夹里的.json文件只支持命名为大于0的数字。 可以从其他机器导入任务只需要打开此目录的EasySpider软件右键“显示包内容”然后把其他机器的tasks文件夹里的.json文件放入/Users/你的用户名/Library/Application Support/EasySpider/tasks文件夹里即可。同理执行号文件可以通过复制execution_instances文件夹中的.json文件来导入。注意两个文件夹里的.json文件只支持命名为大于0的数字。
MacOS版本的软件有一个问题可能存在,即软件所调用的Chrome软件会在打开后经常性自动更新,但软件所依赖的Chromedriver版本并不会随着chrome自动更新,从而导致软件打不开chrome的问题。注意此版本的EasySpider使用的Chrome为111.0版本如果使用过程中发现Chrome无法打开请到Github Issues页面提issue作者将会更新最新版本的软件供大家使用。 MacOS版本的软件有一个问题可能存在,即软件所调用的Chrome软件会在打开后经常性自动更新,但软件所依赖的Chromedriver版本并不会随着chrome自动更新,从而导致软件打不开chrome的问题。注意此版本的EasySpider使用的Chrome为111.0版本如果使用过程中发现Chrome无法打开请到Github Issues页面提issue作者将会更新最新版本的软件供大家使用。
@ -19,7 +19,7 @@ https://github.com/NaiboWang/EasySpider/wiki/MacOS-Guide
File access permissions must be granted, microphone permissions are not necessary at all, and the author is not sure why microphone permissions are being requested, so they can be declined. File access permissions must be granted, microphone permissions are not necessary at all, and the author is not sure why microphone permissions are being requested, so they can be declined.
You can import tasks from other machines by simply opening the EasySpider software in this directory, right-clicking "Show Package Contents", and then placing the .json files from the tasks folder in the Contents/Resources/app/tasks folder of the other machine. Similarly, execution ID files can be imported by copying the .json files from the execution_instances folder. Please note that the .json files in both folders only support names greater than 0. You can import tasks from other machines by simply opening the EasySpider software in this directory, right-clicking "Show Package Contents", and then placing the .json files from the tasks folder in the /Users/your user name/Library/Application Support/EasySpider/tasks folder of the other machine. Similarly, execution ID files can be imported by copying the .json files from the execution_instances folder. Please note that the .json files in both folders only support names greater than 0.
There is a potential issue with the software for MacOS, in that the Chrome software called by the software often updates automatically after opening, but the version of Chromedriver that the software relies on does not update automatically with Chrome, leading to the problem of being unable to open Chrome. Note that the EasySpider version used for Chrome is 111.0. If Chrome cannot be opened during use, please report the issue on the GitHub Issues page, and the author will update the latest version of the software for everyone to use. There is a potential issue with the software for MacOS, in that the Chrome software called by the software often updates automatically after opening, but the version of Chromedriver that the software relies on does not update automatically with Chrome, leading to the problem of being unable to open Chrome. Note that the EasySpider version used for Chrome is 111.0. If Chrome cannot be opened during use, please report the issue on the GitHub Issues page, and the author will update the latest version of the software for everyone to use.