Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # 2ch.hk image dumper
- # Usage: execute in PowerShell by right click or pass thread URLs as arguments
- # (multiple threads allowed); passing args require execution policy
- function Get-2chimages ($threadurl) {
- if ( -not ($threadurl -match "^http[s]{0,1}://2ch\.(hk|pm)/[a-z]+/res/[0-9]+\.html$") ) {
- echo "URL is not valid!"
- return 1
- }
- $threadid = $threadurl.Substring($threadurl.LastIndexOf("/") + 1)
- echo 'Downloading thread $threadid...'
- $pagedata = wget $threadurl
- if (-not $?) {
- echo "Can't donwload $threadurl!"
- return 2
- }
- echo 'Finding images...'
- $imgs = echo $pagedata.Links | where href -match "^/[a-z]?/src/.*\.(jpg|png|gif|webm)" | select href
- md imgs$threadid
- echo 'Downloading images...'
- foreach ($img in $imgs) {
- $dld = "http://2ch.pm" + $img.href
- $filename = "imgs$threadid" + "\" + $dld.Substring($dld.LastIndexOf("/") + 1)
- wget $dld -OutFile $filename
- }
- }
- if (-not $args) {
- $threadurl = Read-Host 'Enter full thread URL'
- Get-2chimages $threadurl
- }
- else {
- foreach ($threadurl in $args) {
- Get-2chimages $threadurl
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment