Yes, I know there are a million of these, so this will make one million and one.
This is a image downloader for Reddit. Many of the images on Reddit are simply linked and can be downloaded directly from the XML source. This example configures a web proxy, and downloads from the /r/pics subboard.
# .NET class
$webClient = new-object System.Net.WebClient
# specify your proxy address and port
$proxy = new-object System.Net.WebProxy "proxy.company.com:8080"
# replace your credential by your domain, username, and pasword
$proxy.Credentials = New-Object System.Net.NetworkCredential ("DomainUserName", "Password")
$webclient.proxy=$proxy
# specify an header if you want to check info in your logs on your proxy
$webClient.Headers.Add("user-agent", "Windows Powershell WebClient Header")
# File to download
$url = "http://reddit.com/r/pics/.xml"
[xml]$myxml = $Webclient.Downloadstring($url)
$myxml.rss.channel.item.description.split("<") | %{$_| select-string -pattern link} | %{$webclient.DownloadFile($_.line.split('"')[1],"c:tempred" + $_.line.split('"')[1].split("/")[-1] )}
Comments
Post a Comment