在我尝试让脚本获取密码(我已经知道我的帐户密码)后几个小时,我被锁在Facebook帐户之外。我的python脚本中有问题,还是我尝试使用它的方式错了?
脚本:
passwordsfile = open('file.txt','r')
for pwd in psswordsfile.read():
br = mechanize.Browser()
br.set_handle_robots(False)
br.addheader = ['User-Agent','Firefox']
br.open('https://www.facebook.com')
br.select_form(nr=0)
br.form['email'] = "emai@..."
br.form['pass'] = pwd
sub = br.submit()
print sub.geturl()
答案 0 :(得分:0)
此错误很简单。 “经常尝试”意味着您在X时间内发送了太多请求。您应该在迭代之间import re
key = "hello world is a good idea for a T-shirt"
pat = r"\W+".join([re.escape(x) for x in key.split()])
# print(pat) # => hello\W+world\W+is\W+a\W+good\W+idea\W+for\W+a\W+T\-shirt
text = "This is some string, that includes commas, and other punctuations. It also includes hello world, is a, good, idea for a T-shirt and other."
match = re.search(pat, text)
if match:
print("YES!")
。
sleep
根据您的迭代次数,5秒可能不够。这是一个反复试验的问题。