LIST = [0, 0] def main(): COUNT = 0 isParseAllowed = False file = open("text.txt", "r") for line in file: a = line.split(":") if(a[0].strip(" ") == "Host"): if(a[2].strip(" ").split("/")[2].strip("\n") in ["vk.com", "vkontakte.ru"]): isParseAllowed = True elif a[0].strip(" ") == "Login" and isParseAllowed: LIST[0] = a[1].strip("\n").strip() elif a[0].strip(" ") == "Pwd" and isParseAllowed: LIST[1] = a[1].strip("\n").strip() COUNT += 1 isParseAllowed = False f = open("accounts.txt", "a") f.write(LIST[0] + ":" + LIST[1] + "\n") f.close() print("Done (" + str(COUNT) + " Entries)") if __name__ == '__main__': main()