阅读组合行并拆分和Keycheck python

时间:2019-06-21 07:44:20

标签: python python-requests

1-如何从格式为“ admin:admin”的文本文件中读取组合,并在发布数据中使用它们? 我尝试这样做

f = open("combo.txt", "r")
for x in f:


k = x
print(k)


但是我不知道如何将它们拆分并放入字符串以在Post数据中使用

2-找到成功密钥后,如何使循环停止? 我尝试这样做

f not 'success":false' in r.text:
    print('Logged In')

else:
    print('Logged Out')

f = open("hits.txt","w+")
f.write(MAIL1 + ':' + PASS1 + '\n')
f.close()

它不应该执行f字符串Steps,但是即使组合失败,它也会继续执行并在文件中写入组合

我当前的代码

import requests
import json

URL = 'https://example.net/api/mail.php'


APIKEY1 = input("ENTER YOUR API KEY: ")
MAIL1 = input("ENTER YOUR MAIL: ")
PASS1 = input("ENTER YOUR PASS: ")

#c = open("combo.txt", "r")
#if c.mode == 'r':
#    contents = c.read()

#k = contents
#print(k)

data1 = {'email':MAIL1,
        'passworad':PASS1,
        'apikey':APIKEY1}

r = requests.post(url = URL, data = data1) 

Status_Code = r.status_code
print('Status Code : %s'%Status_Code)

HTTPError = r.raise_for_status()
print('HTTP Errors : %s'%HTTPError)

print('Response Body :-')
print(r.text)

#JSON VAR
js = r.text

#loading JSON
Error = json.loads(js)

if not 'success":false' in r.text:
    print('Status :- Logged In')

else:
    print('Status :- Logged Out')

f = open("hits.txt","w+")
f.write(MAIL1 + ':' + PASS1 + '\n')
f.close()

0 个答案:

没有答案