You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
27 lines
758 B
27 lines
758 B
# 运行图书爬虫
|
|
$cp = "libs\gson-2.10.1.jar;libs\slf4j-api-2.0.9.jar;libs\slf4j-simple-2.0.9.jar;libs\json-20231013.jar;out"
|
|
|
|
# 创建进程
|
|
$psi = New-Object System.Diagnostics.ProcessStartInfo
|
|
$psi.FileName = "java"
|
|
$psi.Arguments = "-cp `"out;$cp`" com.example.crawler.Main"
|
|
$psi.RedirectStandardInput = $true
|
|
$psi.RedirectStandardOutput = $true
|
|
$psi.RedirectStandardError = $true
|
|
$psi.UseShellExecute = $false
|
|
|
|
$p = [System.Diagnostics.Process]::Start($psi)
|
|
|
|
# 输入选择3
|
|
Start-Sleep -Milliseconds 500
|
|
$p.StandardInput.WriteLine("3")
|
|
$stdout = $p.StandardOutput.ReadToEnd()
|
|
$stderr = $p.StandardError.ReadToEnd()
|
|
|
|
# 等待完成
|
|
$p.WaitForExit(120000)
|
|
|
|
Write-Host "=== OUTPUT ==="
|
|
Write-Host $stdout
|
|
Write-Host "=== ERRORS ==="
|
|
Write-Host $stderr
|