Logging into facebook with python

后端 未结 5 1140
忘掉有多难
忘掉有多难 2020-12-09 06:46

If I run the following code 10 times in a row, it will work about half the time and fail the rest. Anyone know why?

import urllib2, cookielib, re, os, sys

c         


        
5条回答
  •  无人及你
    2020-12-09 07:37

    Okay, I think I found the answer by basically looking at the response data.

    "Logout" does not exist - at least for me -, yet, "Log out" and "logout" does (the later appears as logout.php, which probably won't change on different locales). So, for your particular issue, just replace "Log out" with "logout" and you're all set.

    Now, as to why it was working after the first try, I didn't bother to check

    Also, I'd suggest using urllib's urlencode for sending your data to avoid nasty bugs when sending stuff with "&", ";" and other characters used for control. (The "@" from the e-mails should be encoded also, but it doesn't seem to break this particular case)

    Note: My test was basically changing the string and running it over a loop for some time, no issues were detected. If it does break for you, maybe Andrey is right.

提交回复
热议问题