Advertisement
Guest User

Get-HelloProjectDigitalBooks.ps1

a guest
Sep 23rd, 2018
590
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. # Get-HelloProjectDigitalBooks.ps1
  2.  
  3. [System.IO.Directory]::SetCurrentDirectory([System.Environment]::GetFolderPath('Desktop'))
  4.  
  5. $ie = New-Object -ComObject InternetExplorer.Application
  6. $ie.Visible = $true
  7. $ie.Navigate("http://www.helloproject-digitalbooks.com/")
  8. while ($ie.Busy) {
  9.     Start-Sleep -Milliseconds 100
  10. }
  11. $volume = if ($ie.Document.documentElement.outerHTML -match '"sample/(\d+)/') { $Matches[1] }
  12.  
  13. [void](Read-Host "Hello! Project digitalbooksのホームページが表示されたらログインし、その後にEnterキーを押してください。")
  14. $cookie = $ie.Document.cookie
  15.  
  16. Write-Host "Volume: $volume"
  17. Write-Host "Cookie: $cookie"
  18.  
  19. $webClient = New-Object System.Net.WebClient
  20. $webClient.Headers.Add("Cookie", $cookie)
  21.  
  22. $url_format = "https://www.helloproject-digitalbooks.com/image.php?c=slide&v={0:d1}&id={1:d3}"
  23. $file_format = "$volume-{0:d1}-{1:d3}.jpg"
  24.  
  25. foreach ($v in 1..4) {
  26.     foreach ($id in 1..30) {
  27.         $file = "No image"
  28.         $data = $webClient.DownloadData(($url = $url_format -f $v, $id))
  29.         if ($data.Length -gt 0) {
  30.             [System.IO.File]::WriteAllBytes(($file = $file_format -f $v, $id), $data)
  31.         }
  32.         Write-Host "$url : $file"
  33.     }
  34. }
  35.  
  36. Write-Host "ダウンロードが終了しました。ブラウザを閉じてください。"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement