为什么这个论点不起作用?
Why is the argument not woking?
参数在直接作为字符串传递时有效,但在作为变量传递时无效。
我在没有线程的情况下测试了代码,我直接使用正确的密码作为字符串而不是变量测试了代码并且它有效。我检查了所有级别的参数仍然是正确的类型(字符串)但是在请求中它不起作用,登录不起作用。
import requests
import threading
def checkfor(word):
# word is passed as the password.
payload = {'email':'my_email_here','password': word,'action':'login'}
r = requests.post('https://_a_website_here_.org/rpc.php', data=payload)
lookfor = "userkey"
page_content = r.content
if lookfor.encode() in page_content:
print('[***>>>>>>>] your password is {}.[<<<****]'.format('-'))
else:
print('{}'.format('-'))
threads = []
pw_list = open('pw_list.txt', 'r') # passwords list
pw_line = pw_list.readlines()
pw_linex = pw_line[0:2] # for testing just get 2 first and it has the password set on 2nd place.
for i in range(len(pw_linex)):
word = str(pw_line[i])
print(word)
t = threading.Thread(target=checkfor, args=[word]) #if I insert the password as a string here it works.
t.start()
threads.append(t)
for thread in threads:
thread.join()
密码在列表中,它应该登录并告诉我找到的密码。但它无法以某种方式这样做。有人可以给我解释这段代码吗?谢谢!
从文件中读取文本,每行末尾都有 "\n"
行 - 您必须将其删除(剥离)才能获得正确的单词。要检查您是否没有 "\n"
或空格(您可能看不到),您可以打印 ">word<"
#for word in pw_line[:2]:
for word in pw_linex:
word = word.strip()
print(">{}<".format(word)) # older python
#print(f">{word}<") # python 3.6+
参数在直接作为字符串传递时有效,但在作为变量传递时无效。
我在没有线程的情况下测试了代码,我直接使用正确的密码作为字符串而不是变量测试了代码并且它有效。我检查了所有级别的参数仍然是正确的类型(字符串)但是在请求中它不起作用,登录不起作用。
import requests
import threading
def checkfor(word):
# word is passed as the password.
payload = {'email':'my_email_here','password': word,'action':'login'}
r = requests.post('https://_a_website_here_.org/rpc.php', data=payload)
lookfor = "userkey"
page_content = r.content
if lookfor.encode() in page_content:
print('[***>>>>>>>] your password is {}.[<<<****]'.format('-'))
else:
print('{}'.format('-'))
threads = []
pw_list = open('pw_list.txt', 'r') # passwords list
pw_line = pw_list.readlines()
pw_linex = pw_line[0:2] # for testing just get 2 first and it has the password set on 2nd place.
for i in range(len(pw_linex)):
word = str(pw_line[i])
print(word)
t = threading.Thread(target=checkfor, args=[word]) #if I insert the password as a string here it works.
t.start()
threads.append(t)
for thread in threads:
thread.join()
密码在列表中,它应该登录并告诉我找到的密码。但它无法以某种方式这样做。有人可以给我解释这段代码吗?谢谢!
从文件中读取文本,每行末尾都有 "\n"
行 - 您必须将其删除(剥离)才能获得正确的单词。要检查您是否没有 "\n"
或空格(您可能看不到),您可以打印 ">word<"
#for word in pw_line[:2]:
for word in pw_linex:
word = word.strip()
print(">{}<".format(word)) # older python
#print(f">{word}<") # python 3.6+