Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3948b52

Browse files
committed
Update for an Issue #429
1 parent 9105409 commit 3948b52

2 files changed

Lines changed: 25 additions & 3 deletions

File tree

lib/core/option.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -479,7 +479,21 @@ def _setCrawler():
479479
if not conf.crawlDepth:
480480
return
481481

482-
crawl(conf.url)
482+
if not conf.bulkFile:
483+
crawl(conf.url)
484+
else:
485+
targets = getFileItems(conf.bulkFile)
486+
for i in xrange(len(targets)):
487+
try:
488+
target = targets[i]
489+
crawl(target)
490+
491+
if conf.verbose in (1, 2):
492+
status = '%d/%d links visited (%d%%)' % (i + 1, len(targets), round(100.0 * (i + 1) / len(targets)))
493+
dataToStdout("\r[%s] [INFO] %s" % (time.strftime("%X"), status), True)
494+
except Exception, ex:
495+
errMsg = "problem occured while crawling at '%s' ('%s')" % (target, ex)
496+
logger.error(errMsg)
483497

484498
def _setGoogleDorking():
485499
"""

lib/utils/crawler.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,17 +102,25 @@ def crawlThread():
102102
threadData.shared.deeper = set()
103103
threadData.shared.unprocessed = set([target])
104104

105-
logger.info("starting crawler")
105+
infoMsg = "starting crawler"
106+
if conf.bulkFile:
107+
infoMsg += " for target URL '%s'" % target
108+
logger.info(infoMsg)
106109

107110
for i in xrange(conf.crawlDepth):
108111
if i > 0 and conf.threads == 1:
109112
singleTimeWarnMessage("running in a single-thread mode. This could take a while")
113+
110114
threadData.shared.count = 0
111115
threadData.shared.length = len(threadData.shared.unprocessed)
112116
numThreads = min(conf.threads, len(threadData.shared.unprocessed))
113-
logger.info("searching for links with depth %d" % (i + 1))
117+
118+
if not conf.bulkFile:
119+
logger.info("searching for links with depth %d" % (i + 1))
120+
114121
runThreads(numThreads, crawlThread)
115122
clearConsoleLine(True)
123+
116124
if threadData.shared.deeper:
117125
threadData.shared.unprocessed = set(threadData.shared.deeper)
118126
else:

0 commit comments

Comments
 (0)