From be29a9948788fc002b52a63eeddc31b98644285d Mon Sep 17 00:00:00 2001 From: Marrub Date: Tue, 17 May 2016 13:36:55 -0400 Subject: [PATCH] bookmark_get utility some shit I made to dump tabs from my browser to files --- bookmark_get.ps1 | 51 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 bookmark_get.ps1 diff --git a/bookmark_get.ps1 b/bookmark_get.ps1 new file mode 100644 index 0000000..d188075 --- /dev/null +++ b/bookmark_get.ps1 @@ -0,0 +1,51 @@ +param( + [switch] $no_output, + [switch] $check, + [string] $fname +) + +$uagent = "Mozilla/5.0 (Windows NT 6.2; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/27.0.1453.94 Safari/537.36" +$progressPreference = 'silentlyContinue' + +foreach($line in [System.IO.File]::ReadLines($fname)) +{ + $outf = "output/" + ($line -split '/')[-1].split(':')[0] + + if(test-path $outf) { + continue + } + + if($line -contains "pixiv") { + $head = @{"Referer" = "http://i1.pixiv.net/"} + } else { + $head = @{} + } + + echo "Getting $line" + + try + { + if($no_output -or $check) { + $r = Invoke-WebRequest -useragent $uagent -header $head -uri $line -sessionvariable ofp -erroraction stop -timeout 60 + } + else + { + echo "Output: $outf" + $r = Invoke-WebRequest -useragent $uagent -header $head -uri $line -sessionvariable ofp -erroraction stop -timeout 60 -outfile $outf + } + } + catch + { + echo $r + echo $line | out-file -append failed_links.txt + continue + } + + if($check) + { + if(-not (test-path $outf)) { + $line | out-file -append nonexisting_links.txt + } + } +} +