Guest User

Untitled

a guest
Aug 5th, 2015
247
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. param
  2. (
  3. [string]$board="b",
  4. [string]$tnum="-1",
  5. [string]$sp="e:/pic_dir/"
  6. )
  7.  
  8. $sp += "$board-$tnum"
  9. $thread_path = "https://2ch.hk/$board/res/$tnum.html"
  10. $linq_query = "*/src/*"
  11. $pics_count = 0
  12. $pics_size = 0.0
  13.  
  14. $pics_links = ( ( Invoke-WebRequest -Uri $thread_path ).Links | Where outerHTML -like $linq_query ).href
  15.  
  16.  
  17. if( $pics_links.Count -gt 0 )
  18. {
  19. if( ( Test-Path $sp ) -eq 0 )
  20. {
  21. mkdir $sp
  22. }
  23.  
  24. $elapsed = [System.Diagnostics.Stopwatch]::StartNew()
  25.  
  26. For( $i = 0; $i -lt $pics_links.Count; $i++ )
  27. {
  28. $file_name = $pics_links[$i].Substring( $pics_links[$i].LastIndexOf("/") + 1 )
  29.  
  30. if( ( Test-Path ( "$sp/$file_name" ) ) -eq 0 )
  31. {
  32. $pics_links[$i] = "https://2ch.hk" + $pics_links[$i]
  33. Start-BitsTransfer $pics_links[$i] $sp
  34. $pics_count += 1
  35. $pics_size += ( Get-Item "$sp/$file_name" ).Length / 1024
  36. }
  37. }
  38.  
  39. $pics_size /= 1024
  40. Write-Host ( "Total downloaded content: $pics_count" )
  41. Write-Host ( "Total size: {0:N2} Mb " -f $pics_size )
  42. Write-Host ( "Total elapsed time: $( $elapsed.Elapsed.ToString() )" )
  43. }
  44. else
  45. {
  46. Write-Host "No content in $thread_path or thread 404'd"
  47. }
Advertisement
Add Comment
Please, Sign In to add comment