Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from tumblr import Api
- import tumblr
- import urllib2
- import sys
- errors = {
- ‘403’:”Login o password incorrectos”,
- ‘404’: “Tumblrblog incorrecto”,
- ‘urlopen’ : “no ingreso su tumblrblog”
- }
- BLOG= ”
- USER=’tumail’
- PASSWORD=’tupassword’
- if len(sys.argv) != 3:
- print “Usage: ‘EL TITULO’ ‘EL CUERPO’”
- sys.exit(-1)
- title = sys.argv[1]
- body = sys.argv[2]
- api = Api(BLOG, USER,PASSWORD)
- try:
- post = api.write_regular(title,body)
- print “Published: “, post[‘url’]
- except tumblr.TumblrAuthError:
- print errors[‘403’]
- except urllib2.HTTPError:
- print errors[‘404’]
- except urllib2.URLError:
- print errors[‘urlopen’]
Add Comment
Please, Sign In to add comment