Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $scrapingUrl="http://asite.com"
- $fullPathIncFileName = $MyInvocation.MyCommand.Definition
- $currentScriptName = $MyInvocation.MyCommand.Name
- $currentExecutingPath = $fullPathIncFileName.Replace($currentScriptName, "")
- $jsPath = $currentExecutingPath + "js/scraping.js"
- $si = New-Object -TypeName System.Diagnostics.ProcessStartInfo
- $si.FileName = "D:\Distrib\phantomjs\phantomjs.exe"
- $si.Arguments = "--proxy-type=none --load-images=no $jsPath $scrapingUrl"
- $si.StandardOutputEncoding = [System.Text.Encoding]::UTF8
- $si.RedirectStandardOutput = $TRUE
- $si.UseShellExecute = $FALSE
- $si.CreateNoWindow = $TRUE
- $process = [System.Diagnostics.Process]::Start($si)
- $started = $FALSE;
- while (-not $process.StandardOutput.EndOfStream)
- {
- Start-Sleep 1
- $process.Refresh();
- $line = $process.StandardOutput.ReadLine()
- if($started){
- $Output = $Output + $line
- }
- if($line -eq ">>>>>>>data>>>>>>>"){ #data marker
- $started = $TRUE
- }
- }
- $Output|Out-File "result.txt"
- Write-Host $Output
Advertisement
Add Comment
Please, Sign In to add comment