Commit f9459ab8 authored by dmknght's avatar dmknght

Fix parser and filter

parent 22b282f1
Pipeline #1349 canceled with stages
......@@ -77,7 +77,7 @@ proc printResult() =
for eachResult in allDorkResults:
echo "| Title: " & "\e[31m" & eachResult.title & "\e[0m"
echo "| URL: " & "\e[33m" & decodeURL(eachResult.realURL) & "\e[0m"
echo "| Cache: " & "\e[34m" & decodeURL(eachResult.cacheURL) & "\e[0m"
echo "| Cache: " & "\e[94m" & decodeURL(eachResult.cacheURL) & "\e[0m"
echo "-".repeat(70)
......@@ -126,24 +126,24 @@ proc getResult(resp: AsyncResponse, ext: string) =
else:
let allResults = parseHTML(waitfor(resp.body))
for eachResult in allResults.findAll("div"):
# Filter all result thing
if eachResult.attr("class") == "r":
let
urlResults = eachResult.findAll("a")
titleResults = eachResult.findAll("h3")
var
tmpCacheURL = ""
dorkResult: DorkFile
try:
tmpCacheURL = urlResults[2].attr("href")
except IndexError:
tmpCacheURL = "No web cache URL found"
# # Filter all result thing
let
urlResults = eachResult.findAll("a")
titleResults = eachResult.findAll("h3")
var
tmpCacheURL = ""
dorkResult: DorkFile
if urlResults == @[]:
continue
try:
tmpCacheURL = urlResults[2].attr("href")
except IndexError:
tmpCacheURL = "No web cache URL found"
try:
dorkResult = DorkFile(
title: titleResults[0].innerText,
realURL: urlResults[0].attr("href"),
realURL: if urlResults[0].attr("href").startsWith("/url?q="): urlResults[0].attr("href")[ 7 .. ^1] else: urlResults[0].attr("href"),
cacheURL: tmpCacheURL,
)
......@@ -155,8 +155,10 @@ proc getResult(resp: AsyncResponse, ext: string) =
allDorkResults.add(dorkResult)
break
else:
if dorkResult.realURL.endsWith("." & ext):
allDorkResults.add(dorkResult)
# if dorkResult.realURL.endsWith("." & ext):
allDorkResults.add(dorkResult)
except:
discard
proc basicSearch(domain, extension, query, agent: string) =
......
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