Commit 1baea8c4 authored by dmknght's avatar dmknght

Add filter by response code

parent 2c6ee20c
Pipeline #1445 canceled with stages
......@@ -2,7 +2,7 @@ import httpClient
import htmlparser
import xmltree
import asyncdispatch
from strutils import intToStr, repeat, split, startsWith, endsWith, replace, contains
import strutils
from uri import encodeURL, decodeURL
from os import paramCount, paramStr, getCurrentDir, dirExists, createDir, getHomeDir
......@@ -92,20 +92,24 @@ proc downloadFiles(folder: string, agent: string) =
for eachResult in allDorkResults:
let
fileName = decodeUrl(eachResult.realURL).split("/")[^1]
finalPath = folder & fileName
finalPath = if not contains(fileName, "&"): folder & fileName else: folder & fileName.split("&")[0]
try:
# Downloading -> yellow
# Saved at -> cyan
# Error: read
let resp = waitFor(client.get(eachResult.realURL))
if resp.status != "200 OK":
continue
echo "[+] Downloading \e[33m" & eachResult.realURL & "\e[0m"
waitFor(client.downloadFile(eachResult.realURL, finalPath))
echo "[*] Saved at \e[96m" & finalPath & "\e[0m"
downloaded += 1
except:
stderr.write("[x] Error " & getCurrentExceptionMsg() & " \e[31m" & eachResult.realURL & "\e[0m\n")
if eachResult.cacheURL != "No web cache URL found":
echo "[-] Download from cache is not supported. Please try it manually: " & eachResult.cacheURL
discard
# stderr.write("[x] Error " & getCurrentExceptionMsg() & " \e[31m" & eachResult.realURL & "\e[0m\n")
# if eachResult.cacheURL != "No web cache URL found":
# echo "[-] Download from cache is not supported. Please try it manually: " & eachResult.cacheURL
echo "[*] Downloaded " & intToStr(downloaded) & " files"
client.close()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment