skidd Skrevet 5. juli 2011 Skrevet 5. juli 2011 Hei. er det noen her som har noen gang komt over/laget et program som du f.eks. kan skrive inn en nettside, deretter søker den opp alle bilder som ligger på den siden sånn du kan laste dem ned, istede for å finne hvert enkelt bilde, deretter høgreklikke å laste ned hvert enkelt? Takk for alle svar :-)
Spartakus Skrevet 13. juli 2011 Skrevet 13. juli 2011 Jeg har laget noe slikt ved hjelp av: - PowerShell 2.0, http://support.microsoft.com/kb/968929 - HtmlAgilityPack, http://htmlagilitypack.codeplex.com/ - cURL, http://curl.haxx.se/ Her er et eksempel som laster ned en side med forumtråder og looper alle disse trådene på jakt etter bildelinker. Den støtter også å besøke sider som går over flere sider. Bakdelen er at sånne script stort sett må customizes til hver enkelt forum. $basedir="F:\rip\" add-type -Path ($basedir+"\HtmlAgilityPack.dll") Add-Type -AssemblyName System.Web F: cd\ cd rip write-host "Downloading thread index..." $mainurl = "http://www.site.com/forum" & curl -s -b c.txt -c c.txt -o index.html $mainurl $file = ($basedir +"index.html") $doc = New-Object HtmlAgilityPack.HtmlDocument $result = $doc.Load($file) $threads = $doc.DocumentNode.SelectNodes("//tbody[@id='threadbits_forum_30']/tr") foreach ($thread in $threads) { $threadlink = $thread.SelectSingleNode(".//a[contains(@id, 'thread_title')]") $title = $threadlink.InnerHtml $dltitle = $title.Replace(";","").Replace(":","").Replace("?","").Replace("\","").Replace("/","").Replace(".","").Replace(""","") $url = $threadlink.Attributes["href"].Value $file = $url.Substring($url.LastIndexOf(”/”) + 1) write-host "Downloading: " $file if (!(Test-path ($basedir+$dltitle))){New-Item ($basedir+$dltitle) -type directory | out-null} & curl -s -b c.txt -c c.txt -o ($dltitle+"\"+$file) $url $threadcontent = New-Object HtmlAgilityPack.HtmlDocument $result = $threadcontent.Load(($basedir+$dltitle+"\"+$file)) $mainpage = $false $hasnextpage = $false $pagecounter = 1 write-host $title while((!$mainpage) -or ($hasnextpage)) { if($hasnextpage) { $pagecounter++ write-host " Downloading next page:" $pagecounter $nextpageurl = $nextpage.Attributes["href"].Value $nextfile = $nextpageurl.Substring($nextpageurl.LastIndexOf(”/”) + 1) write-host " Downloading next page: " $nextfile & curl -s -b c.txt -c c.txt -o ($dltitle + "\" +$nextfile) $nextpageurl $result = $threadcontent.Load(($basedir+$dltitle + "\"+$nextfile)) del ($basedir+$dltitle + "\"+$nextfile) } $nextpage = $threadcontent.DocumentNode.SelectSingleNode("//a[@class='smallfont' and text()='>']") $hasnextpage = ($nextpage -ne $null) $mainpage = $true #getting all attachment links $attachments = $threadcontent.DocumentNode.SelectNodes("//a[(contains(@href, 'attachment.php') or contains(@href, 'album.php')) and not(contains(@href, 'thumb'))]") write-host " Attachment count page " $pagecounter ": " $attachments.Count if($attachments -ne $null) { foreach($attachment in $attachments) { if ($attachment.Attributes["id"] -eq $null) { $id = $attachment.Attributes["pictureid"].Value } else { $id = $attachment.Attributes["id"].Value } $link = $attachment.Attributes["href"].Value.Replace("&","&") $link = $link.Replace("album.php","") if(!$link.StartsWith("http")){$link = ($mainurl + "picture.php" + $link)} write-host " Attachment url" $link cd $dltitle & curl -s -b ..\c.txt -c ..\c.txt -J -O -m 30 $link cd.. } } } }
Anbefalte innlegg
Opprett en konto eller logg inn for å kommentere
Du må være et medlem for å kunne skrive en kommentar
Opprett konto
Det er enkelt å melde seg inn for å starte en ny konto!
Start en kontoLogg inn
Har du allerede en konto? Logg inn her.
Logg inn nå