Python 㧠import twitter ã¨è¨è¿°ã㦠2, 3 è¡æ¸ããããã¯ã©ã¹ãè¦ã¤ãããªããã¨ããã¨ã©ã¼ã«ééãã¦ãããã¼ããã¾ããã ã¡ãã£ã¨æ¤ç´¢ããããPython ã® Twitter ã©ã¤ãã©ãªã«ã¯ python-twitter 㨠twitter ããããããããå¥ã ã§ããã®ã§ã¡ã¢ãã¦ããã¾ãã ãªãã httplib2 㨠oauth2 ã¯ã¤ã³ã¹ãã¼ã«ãã¦ããã PYTHONPATH ãéã£ã¦ãããã®ã¨ãã¾ãã Google App Engine ãªã©ã§ä½¿ãå ´å (éçºç°å¢ä»¥å¤ã«é å¸ããå¿ è¦ãããå ´å) ã«ã¯é©å½ãª buildout ã®ã¬ã·ããæ¢ããã google-api-python-client ã®ããã±ã¼ã¸ããã³ãã¼ããã°è¯ãã¨æãã¾ãã ã¡ãã£ã¨åã®è¨äº (Google API Python Client) ã®ããã« Mercurial ã§ãã¼ã«ã«ãã·ã³ã«æ
Twitter APIã®Python ã©ããã¼ã©ã¤ãã©ãªã®ã¤ã³ã¹ãã¼ã«æé ã以ä¸ã«ç´¹ä»ã å®è¡ç°å¢ã¯ä»¥ä¸ã®éãã OS ï¼Windows7 Pythonã®å®è¡ãã¹ ï¼C:\Python27 ãã¦ã³ãã¼ããããã® python-twitter ã©ã¤ãã©ãª http://code.google.com/p/python-twitter/ ä¾åã©ã¤ãã©ãª https://pypi.org/project/simplejson/ http://code.google.com/p/httplib2/ http://github.com/simplegeo/python-oauth2 ã¤ã³ã¹ãã¼ã«æé ã¾ããä¾åã©ã¤ãã©ãªãã¤ã³ã¹ãã¼ã«ããããããã解åãããã©ã«ãä¸ã§ä»¥ä¸ã®ã³ãã³ããå®è¡ C:\httplib2-0.6.0>python setup.py install C:\simplejson-
Google App Engine Pythonã®è©±ã§ãã ãGoogle App Engineã§Twitterã®APIãæ±ãããã«ã¯ä½ä½¿ãã®ãããã®ããªãã ã¨ã¡ãã£ã¨ã°ã°ã£ã¦ã¿ãã¨ãããTweepyã¨ããã®ãè¦ã¤ããã¾ããã ããã使ã£ããµã³ãã«ãtweepy-examplesã«ãã£ãã®ã§ãããªãä½ã¨ãªããããããã ãªãã¨æã触ã£ã¦ã¿ã¾ããã ï¼çµå±ãµã³ãã«ã¯ä½¿ããªãã£ãã®ã§ãããæ¬äººãä½ã£ã¦ãã½ããå¤åè¦ã¦ããã¦æã¯ãªããã ã¨æãï¼ ã¾ãåæã¨ãã¦ããããããã¨ã¯ App EngineããOAuthã使ã£ãtwitterã®APIãå©ã ãã®ã¨ãä»äººã®ãã©ã¤ãã¼ããªã¤ã¶ãããã¼ã¿ãè¦ããããã§ã¯ãªããåç´ã«APIãOAuthèªè¨¼ã«ãªã£ã¦ãããOAuthã使ãããã ã ã¤ã¾ãã¦ã¼ã¶ãåã®ã¢ããªã使ã£ã¦èªè¨¼ãããããããªãã®ã§callbackã¨ãããããã®è¦ããªã ã§ãã ã¨ãããã¨ã§ãèª
æ¸ æ°´å®æ²»botã¯ãpythonã§æ¸ããã¦ãã¦Google App Engineä¸ã§åãã¦ãã¾ããã¡ãã£ã¨åã«ãGoogle App Engineãcronããµãã¼ãããã¨ããã®ãèããã®ã§ãããã試ãã¦ã¿ããã¦ãã®ç°å¢ã§ä½ã£ã¦ã¿ã¾ããããããç°¡åã ã£ãã®ã§ãä½ãæ¹ãç´¹ä»ãã¾ãã Twitterã¸ã®æ稿ã«ã¯ãPython Twitterã¦ã®ã使ã£ã¦ã¿ã¾ããããããã便å©ãªä¸ã®ä¸ã§ãããå 人ã«æè¬ã§ããã¡ãã£ã¡ãã¨æ軽ã«ããããã£ãã®ã§ããã¼ã¿ã¯ãã¡ã¤ã«ããèªãããã«ãã¾ãããããã§ã¯1æ¥1Twitããbotãä½ãã®ã§ããã¼ã¿ãã¡ã¤ã«ã¯ãã·ã³ãã«ã«æ¥ä»ã¨ããã¹ããã«ã³ãã§åºåã£ãè¡ããã ãã©ãã©ã¨ä¸¦ã¶æ§é ã«ãã¾ããããã¼ã¿ãã¡ã¤ã«ã¯data.txtã¨ããååã§ãUTF-8ã§ä¿åãã¦ãã ããã 9/9,å®ã«ç§æ´ãktkr 9/10,æ¯æ²»ã¨å°æ£ãæããã¾ã ã¾ã ã¬ãã«ã¯è² ããªããw : : : ã¡ã¤
Python ã®ã³ã¼ããçºãã¦ãã¨æã ç»å ´ãã¦ããããã¤â if __name__ == '__main__': ãã¼ã£ã¨è¬ã ã£ããã©ããã£ã¨æå³ãåãã£ãï¼ãifã®ä¸èº«ã¯ã¹ã¯ãªãããã¡ã¤ã«ã¨ãã¦å®è¡ãããæã«ã ãå®è¡ããããããã ãããªçå± ã¹ã¯ãªãããã¡ã¤ã«ã¨ãã¦å®è¡ããã㨠__name__ ã£ã¦ããå¤æ°ï¼ãã« '__main__' ã£ã¦ããæååãå ¥ãã Python ã®ã¹ã¯ãªããã import ãããæ㯠__name__ ã«ã¯ import ãããååãå ¥ãã ã¾ãç¾èã¯ä¸è¦ã«ãããã£ã¦ãã¨ã§ããã㪠test.py ãæ¸ãã¦ã¿ãã #! /usr/bin/env python # -*- coding: utf-8 -*- print 'import ã§ãå®è¡ããã __name__ = %s' % __name__ if __name__ == '__main__':
GAE/Pythonã§æåã«æ¸æãã®ã¯RequestHandlerã ã¨æãã¾ããæ°è¦ã¢ããªã±ã¼ã·ã§ã³ä½ææã«èªåçæãããã®ã§å¿ è¦ã«å¿ãã¦æ¸ãæãããã¨ãã§ããã°åé¡ããã¾ããã RequestHandlerã¨ã¯ GAEã«ãã㦠xxxãã¨ããIDã§ã¢ããªã±ã¼ã·ã§ã³ãå ¬éãã㨠http://xxx.appspot.com/ ã¨ããURLãå²ãå½ã¦ããã¾ããã¦ã§ãã¢ããªã±ã¼ã·ã§ã³ã«ã¯ãããããã¼ã¸ãè¨äºã®ãªã¹ããè¨äºã®è©³ç´°ãªã©è¤æ°ã®ãã¼ã¸ãããã¾ãããããããã®ãã¼ã¸ã«ã©ãããURLãå²ãå½ã¦ã¾ããï¼ãããªæãã«å²ãå½ã¦ãå ´åãå¤ãã¨æãã¾ããRequestHandlerã®å½¹å²ã¯URLã¨å¦çãçµã³ã¤ãããã¨ã§ãã ããããã¼ã¸ http://xxx.appspot.com/ è¨äºä¸è¦§ãã¼ã¸ http://xxx.appspot.com/list åå¥è¨äºãã¼ã¸ http://xxx.app
å ã»ã©ç´¹ä»ãããHello World!ãã¢ããªã±ã¼ã·ã§ã³ã¯æãåç´ãªãã®ã§ãPythonè¨èªã®åºæ¬æ©è½ã®ã¿ã使ã£ã¦ä½æãã¾ãããããããGoogle App Engine ã«ã¯å¹ççã«Webã¢ããªã±ã¼ã·ã§ã³ãä½æããããã®ãwebapp Frameworkãããããããæè¼ããã¦ãã¾ãããã®å ¥éç·¨ã®æå¾ã§ã¯ããã®webapp Frameworkã使ã£ãåºæ¬çãªéçºæ¹æ³ãç´¹ä»ãã¾ãããã ããã§ã¯ããåãã¦ã®Google App Engineã¢ããªã±ã¼ã·ã§ã³ãHello World!ãã®éçºãã§ç¤ºããã¢ããªã±ã¼ã·ã§ã³ãwebapp Frameworkã使ã£ã¦ä½ãã¾ãã ã¾ãã¢ããªã±ã¼ã·ã§ã³ã®èµ·åãæ ãmainé¢æ°ãä½æãå®è¡ãã¾ããmainé¢æ°ã®å®è¡ã¯æ¬¡ã®ããã«è¨è¿°ãã¾ãã if __name__ == "__main__": main() èå¿ã®mainé¢æ°ï¼functionï¼ã®å®ç¾©ã¯æ¬¡
åæï¼ ã»GAEã«ã¢ã«ã¦ã³ããç»é²æ¸ã¿ã§ãããã¨ã ã»GAE App Engine SDKãã¤ã³ã¹ãã¼ã«æ¸ã¿ã§ãããã¨ã 大ã¾ããªæµãï¼ 1.GAEã«ã¢ããªã±ã¼ã·ã§ã³ãç»é² 2.twitterã«IDãä½æ 3.ã¢ããªã±ã¼ã·ã§ã³ã®å®è£ 4.GAEã¸ã®ã¢ãããã¼ã 1. GAEã«ã¢ããªã±ã¼ã·ã§ã³ãç»é²ï¼ 1-1 https://appengine.google.com/ ã«ã¢ã¯ã»ã¹ããã¢ããªã±ã¼ã·ã§ã³ãç»é²ãã¾ãã
App Engine Python ã®æ¦Â覠Google App Engine for Python ã¸ãÂÂãÂÂãÂÂãÂÂãÂÂApp Engine ã§ã¯ãÂÂPython ãÂÂãÂÂã°ã©ãÂÂã³ã°è¨ÂèªÂãÂÂ使ç¨ãÂÂ㦠Web ã¢ãÂÂãªã±ã¼ã·ã§ã³ãÂÂä½ÂæÂÂã§ãÂÂã¾ãÂÂãÂÂã¾ãÂÂãÂÂéÂÂçºè ãÂÂæÂÂé«Âã‹ÂÂã«ã® Web ã¢ãÂÂãªã±ã¼ã·ã§ã³ã®ä½ÂæÂÂã«使ç¨ãÂÂã Python ç¨ã®å¤Âæ°ã®ã©ã¤ãÂÂã©ãªãÂÂãÂÂã¼ã«ãÂÂãÂÂ㋼ã ã¯ã¼ã¯ãÂÂå©ç¨ã§ãÂÂã¾ãÂÂãÂÂä½ÂæÂÂãÂÂãÂÂ
The webapp Framework The webapp framework is a simple web application framework you can use for developing Python web applications for App Engine. webapp is compatible with the WSGI standard for Python web application containers. webapp provides an easy way to get started developing apps for App Engine. You don't have to use webapp to write Python applications for App Engine. Other web application
2011å¹´7æ24æ¥ãããã¢ããã°ãã¬ãæ¾éã¯çµäºãããã¸ã¿ã«æ¾éã«ç§»è¡ããããã§ãã twitterãããã¤ãããã¯ç¥ããªããã©Basicèªè¨¼ãçµäºããOAuthèªè¨¼ã«ç§»è¡ããããã§ããï¼ å¤§å¤ã§ããï¼ï¼ ç¾å¨ç§ãä½ã£ãtwitter-bot@Korokã§ãããtwitterã¨è©±ã¯python-twitterã§ã¤ãã¦ãã¾ããpython-twitterã¯ã©ãããBasicèªè¨¼ããããããªããæ´æ°ããã£ã¦ãªãã¿ããã ããid:tohaeã¡ãããOAuth対å¿ã¯ããããæ¹ããããã£ã¦äºãããã¡ãã£ã¡ãã¨ãã£ã¡ããã¾ãããã 使ç¨ããã©ã¤ãã©ãªã¯tweepyã å ¬å¼ : GitHub Pages · File Not Found · GitHub ããã¥ã¡ã³ã : GitHub Pages · File Not Found · GitHub åèã«ããã¨ã³ã㪠: Twitterã®botãOA
ã°ãã¼ãã«ã¢ã¸ã¥ã¼ã«ã¤ã³ãã¯ã¹ (å ¨ããã¥ã¡ã³ãã«ãã°ããã¢ã¯ã»ã¹ã§ãã¾ã) ã©ã¤ãã©ãªãªãã¡ã¬ã³ã¹ (æã®ä¸ã«ãã¤ãç½®ãã¦ããã¾ããã) Macintosh ã¢ã¸ã¥ã¼ã«ãªãã¡ã¬ã³ã¹ (Macintosh ã使ã£ã¦ãããªãããã) Python ã¢ã¸ã¥ã¼ã«ã®ã¤ã³ã¹ãã¼ã« (管çè åã) Python ã¢ã¸ã¥ã¼ã«ã®é å¸ (éçºè ï¼ããã±ã¼ã¸ä½æè åã)
Python(lxml)ã§htmlãå¦çãã ã¾ã¨ã Pythonã«ã¯xml/htmlãåãæ±ãããã®lxmlã¨ãã便å©ãªãµã¼ããã¼ãã£ã¢ã¸ã¥ã¼ã«ãããã¾ãã ããã§ã¯ãlxmlã使ã£ã¦htmlãå¦çããéã«ã使ããã¡ã½ãããªã©ãç°¡åã«ã¾ã¨ãã¦ãã¾ãã (ä¾ãHTML5ã使ã£ããã®ãªã®ã§æ°ãã¤ãã¦ãã ããã) åæ©çãªãã®ãç´°ããã¾ã¨ãããã®ã¯ã ãlxmlã§htmlãå¦çãããã«ããã¾ãã ã¾ãã lxml ã«ããå ¨ã¦ã®ã¡ã½ãããç´¹ä»ãã¦ããããã§ã¯ããã¾ããã®ã§ã注æãã 1. htmlã®èªã¿è¾¼ã¿ >>> dom = lxml.html.fromstring(html) >>> dom <Element html at 1967ed8> >>> dom2 = lxml.html.parse('python_tips_003.html') >>> dom2 <lxml.etree._El
å 容 pythonåå¦è åãã®é »åºã¢ã¤ãã ãã¼ãã·ã¼ããä½æãã¦ã¿ã¾ããã A4ç¨ç´ã«å°å·ãã¦ã¡ããã©ããããã«å¿ è¦äºé ãã¿ã£ããã¨æ·ãè©°ãã¦ãã¾ããpythonããã°ã©ãã³ã°ã®ãä¾ã«ã©ããã ç®æ¬¡ ifæ whileæ foræ continue/breakæ è«çæ¼ç® ç®è¡æ¼ç® é¢æ° ãªã¹ã ãã£ã¯ã·ã§ã㪠map ã¿ãã« ã¢ã¸ã¥ã¼ã« ã¯ã©ã¹ ä¾å¤ ã®åºæ¬çãªãã¨ãã§ããã ãããããçãè¾¼ã¿ããã£ãã®ã§è¨è¿°é çªã¯ãã¡ããã¡ããã¦ãã¾ã£ãæãã§ãã è¨è¿°ãã¹ãã£ããããããªãããææããã°ç´ãã¾ã ææ°çã®DL㯠ãã¡ãããã©ãã(v1.1)ã (zip/ç´50kb/ä¸èº«ã¯pdf) å¤ããã¼ã¸ã§ã³ v1.1 ã³ã¡ã³ãã®id:t-tanakaããææãä¿®æ£ b:id:cu39ããã®ã³ã¡ã³ããM+2VM+IPAG circleã§ãããããè¦ã¦ãã©ã³ãããM+2VM+IPAG circleãã«
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ã©ã³ãã³ã°
ãªãªã¼ã¹ãé害æ å ±ãªã©ã®ãµã¼ãã¹ã®ãç¥ãã
ææ°ã®äººæ°ã¨ã³ããªã¼ã®é ä¿¡
å¦çãå®è¡ä¸ã§ã
j次ã®ããã¯ãã¼ã¯
kåã®ããã¯ãã¼ã¯
lãã¨ã§èªã
eã³ã¡ã³ãä¸è¦§ãéã
oãã¼ã¸ãéã
{{#tags}}- {{label}}
{{/tags}}