Revision: 12501
Initial Code
Initial URL
Initial Description
Initial Title
Initial Tags
Initial Language
at March 17, 2009 15:37 by tamuratetsuya
Initial Code
#Twitterã‹ã‚‰ã‚るユーザã®ç›´è¿‘ã®è³ªå•ã‚’ã¨ã£ã¦ãã‚‹ import datetime import locale from datetime import timedelta def GetresponseTwitter(): #urlä½œæˆ d=datetime.datetime.today() dt1 = timedelta(seconds=60*60*9)#twitterã®æ™‚刻ã¯9æ™‚é–“å‰ dt2 = timedelta(seconds=const_time) new_d = d-dt1-dt2#10分å‰ã®æ™‚刻をå–å¾— since=sinceParm(new_d)#sinceパラメータã®ä½œæˆ url = 'http://twitter.com/statuses/replies.xml?since=%s'%since base64string =b64encode("%s:%s" % (username, password))#username,passwordã¯è‡ªåˆ†ã§å®šç¾©ã™ã‚‹ã“㨠headers = {"Authorization": "Basic %s" % base64string} xml_result=urlfetch.fetch(url, payload='', method=urlfetch.POST, headers=headers).content result=[] for soup in BeautifulSoup(xml_result)('status'): try: print >>sys.stderr,'text=%s'%htmlentity2unicode(soup('text')[0](text = True)[0].split(' ')[1]) text=htmlentity2unicode(soup('text')[0](text = True)[0].split(' ')[1]) except: print >>sys.stderr,'text=%s'%htmlentity2unicode(soup('text')[0](text = True)[0].split(' ')[1]) text=htmlentity2unicode(soup('text')[0](text = True)[0].split(' ')[1]) user=htmlentity2unicode(soup('screen_name')[0](text = True)[0]) result.append([text,user]) return result
Initial URL
Initial Description
Initial Title
twitter-apiã«ã‚ˆã‚‹è‡ªåˆ†ã‚¢ã‚«ã‚¦ãƒ³ãƒˆã¸ããŸè¿”ä¿¡ã®å–å¾—
Initial Tags
google, python, django
Initial Language
Python