-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathlareta.py
More file actions
executable file
·38 lines (29 loc) · 1.1 KB
/
lareta.py
File metadata and controls
executable file
·38 lines (29 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/python
# -*- coding: utf-8
#Version 0.2 by Alexandre González <alex _at_ rianxosencabos _dot_ com>
#All the bugs reserved ;)
#version 0.2: added a if to control the maximum of chars (140)
import urllib, urllib2, cookielib
import sys
if len(" ".join(sys.argv[1:])) > 140:
print "Mensaxe demasiado larga, só se permiten 140 caracteres."
quit()
if len(sys.argv) < 2:
print "Necesito polo menos un argumento para postear como chío."
quit()
#Global variables
@@NICKNAME = 'o_teu_nick'
@@PASSWORD = 'a_tua_pass'
#Make the cookie
cookie_h = urllib2.HTTPCookieProcessor()
opener = urllib2.build_opener( cookie_h )
urllib2.install_opener( opener )
#Login
params = urllib.urlencode( { "nickname" : NICKNAME, "password" : PASSWORD } )
req = urllib2.Request( "http://lareta.net/main/login", params )
response = urllib2.urlopen( req )
#Post the status message
params = urllib.urlencode( { 'status_textarea' : " ".join(sys.argv[1:]) } )
req = urllib2.Request( "http://lareta.net/notice/new", params )
response = urllib2.urlopen( req )
print "Chío publicado con éxito."