Multi-Platform Support

This commit is contained in:
NaiboWang-Alienware 2023-02-07 20:44:05 +08:00
parent d0c08ccd97
commit 43aa4dd224
2 changed files with 15 additions and 11 deletions

View File

@ -11,13 +11,13 @@ if (process.platform === 'win32' || process.platform === 'win64') {
chromeBinaryPath = path.join(__dirname, "chrome_win32/chrome.exe"); chromeBinaryPath = path.join(__dirname, "chrome_win32/chrome.exe");
execute_path = path.join(__dirname, "chrome_win32/execute.bat"); execute_path = path.join(__dirname, "chrome_win32/execute.bat");
} else if (process.platform === 'darwin') { } else if (process.platform === 'darwin') {
driverPath = path.join(__dirname, "chrome_mac/chromedriver"); driverPath = path.join(__dirname, "chromedriver_mac64");
chromeBinaryPath = path.join(__dirname, "chrome_mac/Chromium.app/Contents/MacOS/Chromium"); chromeBinaryPath = path.join(__dirname, "chrome_mac64.app/Contents/MacOS/Google Chrome");
execute_path = path.join(__dirname, "chrome_mac/execute.sh"); execute_path = path.join(__dirname, "easyspider_executestage");
} else if (process.platform === 'linux') { } else if (process.platform === 'linux') {
driverPath = path.join(__dirname, "chrome_linux/chromedriver"); driverPath = path.join(__dirname, "chrome_linux64/chromedriver_linux64");
chromeBinaryPath = path.join(__dirname, "chrome_linux/chrome"); chromeBinaryPath = path.join(__dirname, "chrome_linux64/chrome");
execute_path = path.join(__dirname, "chrome_linux/execute.sh"); execute_path = path.join(__dirname, "chrome_linux64/easyspider_executestage");
} }
let server_address = "https://servicewrapper.systems"; let server_address = "https://servicewrapper.systems";
@ -91,7 +91,9 @@ function beginInvoke(msg) {
let spawn = require("child_process").spawn; let spawn = require("child_process").spawn;
let child_process = spawn(execute_path, parameters); let child_process = spawn(execute_path, parameters);
child_process.stdout.on('data', function (data) {
console.log(data.toString());
});
} }
} }

View File

@ -683,8 +683,10 @@ if __name__ == '__main__':
options.binary_location = "EasySpider/resources/app/chrome_linux64/chrome" options.binary_location = "EasySpider/resources/app/chrome_linux64/chrome"
driver_path = "EasySpider/resources/app/chrome_linux64/chromedriver_linux64" driver_path = "EasySpider/resources/app/chrome_linux64/chromedriver_linux64"
elif sys.platform == "darwin" and platform.architecture()[0] == "64bit": elif sys.platform == "darwin" and platform.architecture()[0] == "64bit":
options.binary_location = "EasySpider/chrome_mac64/chrome" options.binary_location = "EasySpider/resources/app/chrome_mac64/chrome"
driver_path = "EasySpider/chrome_mac64/chromedriver_mac64" # MacOS需要用option而不是options
option.binary_location = "EasySpider/resources/app/chrome_mac64/chrome"
driver_path = "EasySpider/resources/app/chrome_mac64/chromedriver_mac64"
else: else:
print("Unsupported platform") print("Unsupported platform")
sys.exit() sys.exit()
@ -693,12 +695,12 @@ if __name__ == '__main__':
elif os.path.exists(os.getcwd()+"/Debug"): elif os.path.exists(os.getcwd()+"/Debug"):
print("Finding chromedriver in EasySpider", print("Finding chromedriver in EasySpider",
os.getcwd()+"/Debug") os.getcwd()+"/Debug")
options.binary_location = "Debug/Chrome/chrome.exe" # 指定chrome位置 option.binary_location = "Debug/Chrome/chrome.exe" # 指定chrome位置
driver_path = "Debug/Chrome/chromedriver.exe" driver_path = "Debug/Chrome/chromedriver.exe"
elif os.getcwd().find("ExecuteStage") >= 0: # 如果直接执行 elif os.getcwd().find("ExecuteStage") >= 0: # 如果直接执行
print("Finding chromedriver in EasySpider", print("Finding chromedriver in EasySpider",
os.getcwd()+"/Debug") os.getcwd()+"/Debug")
option.binary_location = "./Application/chrome.exe" # 指定chrome位置 options.binary_location = "./Application/chrome.exe" # 指定chrome位置
# option.binary_location = "C:\\Users\\q9823\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe" # option.binary_location = "C:\\Users\\q9823\\AppData\\Local\\Google\\Chrome\\Application\\chrome.exe"
driver_path = "./Application/chromedriver.exe" driver_path = "./Application/chromedriver.exe"
else: else: