Webometric Thoughts

August 31, 2008

Twittering with Python …on the web

Filed under: Python,Twitter,programming — admin @ 9:20 pm

Programming is really addictive, especially when you are bad at it. Whilst the proficient programmer can deal with their problems in a matter of minutes, bad programmers can spend hours on the simplest of problems. Today I decided to start messing about with some server-side programming for the first time; now I find myself wondering what happened to my Sunday.

This particular form allows anyone to post to your Twitter account (and then displays the comments that have already been posted):

Enter Comment:

Now all I need to do is think of a use for anonymous twittering….
(http://twitter.com/blogcomments)

The code:
>#!/usr/bin/python
>import cgi
>import urllib
>print “Content-type: text/html\n\n”
>form=cgi.FieldStorage()
>data = urllib.urlencode({“status” : form["status"].value})
>res = urllib.urlopen(“http://USERNAME:PASSWORD@twitter.com/statuses/update.xml”
, data)
>lines = urllib.urlopen(‘http://twitter.com/statuses/user_timeline/16066835.rss’)
.readlines()
>for line in lines:
>>>if line.find(‘title’) <>-1:
>>>>>>line=line[11:(len(line)-9)]
>>>>>>print line

7 Comments »

  1. winded@desires.grabbed” rel=”nofollow”>.…

    ñïàñèáî!…

    Trackback by stanley — November 25, 2014 @ 9:53 am

  2. hess@sheriff.assail” rel=”nofollow”>.…

    áëàãîäàðñòâóþ!…

    Trackback by orlando — December 21, 2014 @ 4:01 pm

  3. sledding@axiom.quarreled” rel=”nofollow”>.…

    ñïñ….

    Trackback by juan — January 16, 2015 @ 7:25 pm

  4. horn@carefulness.peroxide” rel=”nofollow”>.…

    ñïñ….

    Trackback by keith — January 16, 2015 @ 7:54 pm

  5. adventists@freshborn.refueling” rel=”nofollow”>.…

    áëàãîäàðñòâóþ!!…

    Trackback by Jose — January 16, 2015 @ 8:24 pm

  6. coaching@fierceness.unpremeditated” rel=”nofollow”>.…

    ñýíêñ çà èíôó!!…

    Trackback by Adam — January 16, 2015 @ 8:54 pm

  7. spectrometric@satirizes.fritzies” rel=”nofollow”>.…

    ñïñ çà èíôó!…

    Trackback by Reginald — January 16, 2015 @ 9:23 pm

RSS feed for comments on this post. TrackBack URL

Leave a comment

Powered by WordPress