网址文件py.txt内容:
global
log 127.0.0.1 local2
daemon
backend oldboy.org
bind 0.0.0.0:80
option httplog
option httpclose
option forwardfor
log global
backend www.oldboy1.org
server 10.10.0.10 10.10.0.10 weight 9999 maxconn 3333333
server 10.10.10.1 10.10.10.1 weight 22 maxconn 2000
server 2.2.2.4 2.2.2.4 weight 20 maxconn 3000
backend www.oldboy2.org
server 3.3.3.3 3.3.3.3 weight 20 maxconn 3000
backend www.oldboy20.org
server 10.10.0.10 10.10.0.10 weight 9999 maxconn 3333333
--------------------------------------------------
# 标志位
while 1:
m=input("please input url:").strip()
l=[]
flag=False
with open("py.txt",mode="r",encoding="utf8") as f_read:
for line in f_read:
if line.startswith("backend") and m in line:
flag=True
continue
if line.startswith("backend") and flag:
break
if flag:
l.append(line)
for i in l:
print(i)