【发布时间】:2019-06-19 13:38:44
【问题描述】:
这是我的 dir.py 烧瓶
import requests
def dir(domain):
paths = ['/test','/html','/go','/.git']
for path in paths:
path = path.strip()
url = 'http://'+domain+path
result = requests.get(url)
if result.status_code == 200:
return url
dir("localhost")
这是run.py
@app.route('/brute', methods=["GET", "POST"])
def brute():
erroro = ""
if request.method == "POST":
domain = None
try:
if request.form["domain"] == "":
erroro += ("<p>{!r} Input Empty</p>").format(request.form["domain"])
else:
domain = request.form["domain"]
except:
erroro += ("<p>{!r} Input Empty</p>").format(request.form["domain"])
if domain is not None:
brute_res = brute_admin(domain)
return render_template("brute_result.html", brute_res = brute_res)
return render_template('brute.html').format(erroro=erroro)
现在的问题是我正在尝试在网页中打印 url 列表,例如:
但它只是打印带有路径的第一个 url,我尝试了其他方法但没有运气。我现在可以做什么。此外,这个过程需要一些时间,并且结果在完成该过程之前不会显示,我能做到吗在后台执行此操作,稍后我可以下载在dir.py 中编码的 url 列表,如果 status_code == 200 然后返回 url。如果有任何其他方法可以执行此过程,请帮助我。
谢谢,
【问题讨论】:
-
return url- 那是你的问题。只要您return,循环就会结束。 -
顺便说一句,重用像
dir这样的内置名称是个坏主意 -
如果我没有返回它,那么 print func 在控制台中工作。
标签: python python-3.x flask python-requests