tag:blogger.com,1999:blog-6950106.post-80643917494513066572008-06-04T22:13:00.003Z2008-06-04T22:46:30.170Z2008-06-04T22:46:30.170ZPlurk Python Post Script<p>Neville Newey of <a href="http://muti.co.za/" rel="external">muti</a> wrote the following Python script similar in function to the <a href="http://blog.charlvn.za.net/2008/06/plurk.html">PHP script</a> I wrote a bit earlier today. Essentially it lets you post a new message to your <a href="http://www.plurk.com/" rel="external">plurk</a> account.</p>
<pre><code>import urllib
import urllib2
import cookielib
# Based on Charl VN's PHP Code
PLURK_LOGIN_URL = 'http://www.plurk.com/Users/login'
PLURK_ADD_URL = 'http://www.plurk.com/TimeLine/addPlurk'
NICKNAME = 'yourname'
PASSWORD = 'secret'
if __name__ == '__main__':
# Set up
jar = cookielib.CookieJar()
handler = urllib2.HTTPCookieProcessor(jar)
opener = urllib2.build_opener(handler)
# Login phase ...
url = PLURK_LOGIN_URL
values = { 'nick_name': NICKNAME, 'password': PASSWORD }
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = opener.open(req)
# Now plurk something!
values = {'content': 'Plurking from Python!', 'lang':'en', 'no_comments':'0'}
data = urllib.urlencode(values)
data+='&qualifier=%3A' # Dont know if this is needed
url = PLURK_ADD_URL
req = urllib2.Request(url, data)
response = opener.open(req)
print response.read()</code></pre>
<p>This is the base for a new hook script so that you can now <a href="http://www.plurk.com/user/muti" rel="external">follow muti on plurk</a>!</p>Charl van Niekerkhttp://www.blogger.com/profile/16555795103153299929charlvn@charlvn.za.net5