Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- param
- (
- [string]$board="b",
- [string]$tnum="-1",
- [string]$sp="e:/pic_dir/"
- )
- $sp += "$board-$tnum"
- $thread_path = "https://2ch.hk/$board/res/$tnum.html"
- $linq_query = "*/src/*"
- $pics_count = 0
- $pics_size = 0.0
- $pics_links = ( ( Invoke-WebRequest -Uri $thread_path ).Links | Where outerHTML -like $linq_query ).href
- if( $pics_links.Count -gt 0 )
- {
- if( ( Test-Path $sp ) -eq 0 )
- {
- mkdir $sp
- }
- $elapsed = [System.Diagnostics.Stopwatch]::StartNew()
- For( $i = 0; $i -lt $pics_links.Count; $i++ )
- {
- $file_name = $pics_links[$i].Substring( $pics_links[$i].LastIndexOf("/") + 1 )
- if( ( Test-Path ( "$sp/$file_name" ) ) -eq 0 )
- {
- $pics_links[$i] = "https://2ch.hk" + $pics_links[$i]
- Start-BitsTransfer $pics_links[$i] $sp
- $pics_count += 1
- $pics_size += ( Get-Item "$sp/$file_name" ).Length / 1024
- }
- }
- $pics_size /= 1024
- Write-Host ( "Total downloaded content: $pics_count" )
- Write-Host ( "Total size: {0:N2} Mb " -f $pics_size )
- Write-Host ( "Total elapsed time: $( $elapsed.Elapsed.ToString() )" )
- }
- else
- {
- Write-Host "No content in $thread_path or thread 404'd"
- }
Advertisement
Add Comment
Please, Sign In to add comment