Created
January 16, 2010 14:22
-
-
Save mizchi/278835 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/python | |
# -*- encoding:utf8 -*- | |
import mechanize | |
br = mechanize.Browser() | |
br.set_handle_robots(False) | |
url='http://mixi.jp' | |
username="<your email>" | |
password="<your password>" | |
mixi_id=<your id-number> | |
def login(): | |
try: | |
br.open(url) | |
br.select_form(name="login_form") | |
br["email"] = username | |
br["password"] = password | |
br.submit() | |
return True | |
except: | |
return False | |
def write(title,body): | |
br.open('http://mixi.jp/add_diary.pl?id=%u&send_from=home' % mixi_id) | |
br.select_form(name="diary") | |
br["diary_title"] = title.encode(br.encoding()) | |
br["diary_body"] = body.encode(br.encoding()) | |
res=br.submit() | |
print res.geturl() | |
br.submit() | |
if login() : print "Login OK" | |
elif print "Login Failure" | |
write("test","hello") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment