import mechanize,cookielib
br=mechanize.Browser()
cookie_jar=cookielib.CookieJar()
br.set_cookiejar(cookie_jar)
br.addheaders = [('User-agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008071615 Fedora/3.0.1-1.fc9 Firefox/3.0.1')]
br.set_handle_referer(True)
br.set_handle_robots(False)
br.open("http://facebook.com/login.php")
br.select_form(nr=0)
br.form['email']=raw_input("Email please: ")
br.form['pass']=raw_input("Password please: ")
br.submit()
if "Logout" in br.response().read():
print "Successfuly Logged in...May the Spam Process Begin ;) "
else:
print "Something is wrong with logging in.Sorry :( "
link_to_spam=raw_input("Enter the messages link for the one you want to spam\n\
Example: https://www.facebook.com/messages/someone: ")
br.open(link_to_spam)
for f in br.forms():
print f
所以这段代码没有在 facebook 中显示消息表单。不要评论代码的目的。我只是为了好玩而编写它,除非我的朋友接受它,否则实际上不会使用它,但即便如此我不会用太多。有谁知道它为什么不显示?