1
0
Fork 0

bookmark_get utility

some shit I made to dump tabs from my browser to files
master
Marrub 2016-05-17 13:36:55 -04:00
parent ae6e4190c1
commit be29a99487
1 changed files with 51 additions and 0 deletions

51
bookmark_get.ps1 Normal file
View File

@ -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
}
}
}