2005-05-01ãã1ã¶æéã®è¨äºä¸è¦§
WScript.Shellãªãã¸ã§ã¯ãã§ã¯SpecialFoldersããããã£ãå¾ããã¨ãã§ããã ãã®ããããã£ã¯windowsã®ç¹å¥ãªãã©ã«ã(ãã¹ã¯ãããããã¤ããã¥ã¡ã³ããªã©)ã®ãã¹ãå¾ããã¨ãã§ããã >>> import win32com.client >>> com = win32com.client.Dispatch("â¦
win32allã¢ã¸ã¥ã¼ã«ã®ä¸ã®win32com.clientã¯ãwindowsã®COM(Component Object Model)ãªãã¸ã§ã¯ããæä½ããæ¡å¼µã¢ã¸ã¥ã¼ã«ã Python Win32 Extensions(win32all) http://starship.python.net/crew/mhammond/win32/Downloads.html ã³ã¬ã使ããã¨ã§WSHã®ããâ¦
Shift-jisã§ã¯å¤ã«ããã¯ã¹ã©ãã·ã¥(=0x5c)ãå«ã¾ããå ´åãããã(ä¾ãã°"表"ã®å) Pythonã§ã¯ããã¯ã¹ã©ãã·ã¥ã¯ã¨ã¹ã±ã¼ãæåã¨ãã¦æ±ãããã®ã§ããã®ãããªæåãæ£è¦è¡¨ç¾ã®ãã¿ã¼ã³ã«å«ã¾ãã¦ããã¨æå³ããªãçµæã¨ãªãã æååããã£ããunicodeã«â¦
>>>import pykf >>>import urllib >>>url = "http://www.yahoo.co.jp" >>>urlhandler = urllib.urlopen(url) >>>html = urlhandler.read() >>>html = pykf.tosjis(html, pykf.EUC) >>>print html yahooãã¼ã¸ã®æåã³ã¼ãã¯ãEUCããªã®ã§ãSJISãã«å¤æãã â¦
>>>import pykf >>>string = "ããããã" >>>print pykf.guess(string) 2 対å¿è¡¨ ASCII = 1 ERROR = -1 EUC = 3 JIS = 4 SJIS = 2 UNKNOWN = 0 UTF16 = 7 UTF16_BE = 8 UTF16_LE = 7 UTF8 = 5
http://hathawaymix.org/Software/TCPWatchã³ãã³ãã©ã¤ã³ããTCPWatchãèµ·åããã c:>tcpwatch.py -p 127.0.0.1:3128 TCPWatchãset_proxyãã¦ãªã¯ã¨ã¹ããé£ã°ã >>>import urllib2 >>>req = urllib2.Request("http://www.google.co.jp") >>>req.set_proxâ¦
>>>import urllib2 >>>req = urllib2.Request("http://www.google.co.jp") >>>req.set_proxy("proxy.example.com:8080", "http") >>>req.add_header("User-agent", "python") >>>req.add_header("Pragma", "no-cache") >>>site = urllib2.urlopen(req)
>>>import urllib2 >>>req = urllib2.Request("http://www.google.co.jp") >>>req.add_header("User-agent", "python") >>>req.add_header("Pragma", "no-cache") >>>urlhandler = urllib2.urlopen(req)
>>>import urllib2 >>>req = urllib2.Request("http://www.google.co.jp") >>>req.add_header("User-agent", "python") >>>urlhandler = urllib2.urlopen(req)
>>>import urllib2 >>>urlhandler = urllib2.urlopen("http://www.google.co.jp") >>>html = urlhandler.read() ä¸è¡ãã¤èªã¿è¾¼ã >>>html = urlhandler.readline() ä¸è¡ãã¤ãªã¹ãã«æ ¼ç´ >>>html = urlhandler.readlines()