{"id":106,"date":"2014-07-04T10:00:38","date_gmt":"2014-07-04T01:00:38","guid":{"rendered":"http:\/\/www.skyarch.net\/blog\/?p=106"},"modified":"2021-11-02T17:29:37","modified_gmt":"2021-11-02T08:29:37","slug":"ipython%e3%81%ae%e5%88%a9%e7%94%a8","status":"publish","type":"post","link":"https:\/\/www.skyarch.net\/blog\/ipython%e3%81%ae%e5%88%a9%e7%94%a8\/","title":{"rendered":"ipython\u306e\u5229\u7528"},"content":{"rendered":"<h1>\u306f\u3058\u3081\u306b<\/h1>\n<p>\u6709\u540d\u306a\u30c4\u30fc\u30eb\u306a\u306e\u3067ipython\u306b\u3064\u3044\u3066\u3044\u307e\u3055\u3089\u8aac\u660e\u3057\u306a\u304f\u3068\u3082\u4f7f\u3044\u8fbc\u3093\u3067\u3044\u308b\u65b9\u3082\u591a\u3044\u3068\u601d\u3044\u307e\u3059\u304c<br \/>\n<a title=\"http:\/\/ipython.org\/\" href=\"http:\/\/ipython.org\/\" target=\"_blank\" rel=\"noopener\">http:\/\/ipython.org\/<\/a><br \/>\n\u306b\u3066\u914d\u5e03\u3057\u3066\u3044\u308b\u3001\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6shell\u3068\u3057\u3066\u3082\u4f7f\u3048\u308bpython\u3067\u3059\u3002<br \/>\n\u6700\u8fd1\u306f\u30c7\u30fc\u30bf\u5206\u6790\u7cfb\u306e\u65b9\u3005\u306b\u77e5\u540d\u5ea6\u304c\u9ad8\u3044\u3088\u3046\u3067\u3059\u306d\u3002<br \/>\n<!--more--><\/p>\n<h1>\u30a4\u30f3\u30b9\u30c8\u30fc\u30eb<\/h1>\n<p>AmazonLinux\u306e\u5834\u5408\u3001\u6a19\u6e96\u306e\u30ea\u30dd\u30b8\u30c8\u30ea\u306b\u306f\u306a\u3044\u306e\u3067epel\u3092\u5229\u7528\u3057\u3066\u304f\u3060\u3055\u3044\u3002<br \/>\n<code><br \/>\n$ sudo yum --enablerepo=epel install python-ipython<br \/>\n<\/code><\/p>\n<h1>\u5b9f\u884c<\/h1>\n<p>install\u304c\u6b63\u5e38\u306b\u7d42\u308f\u3063\u305f\u3089\u3055\u3063\u305d\u304f\u5b9f\u884c\u3057\u3066\u307f\u307e\u3059\u3002<\/p>\n<pre>$ ipython\nPython 2.6.9 (unknown, Mar 28 2014, 00:06:37)\nType \"copyright\", \"credits\" or \"license\" for more information.\n\nIPython 1.1.0 -- An enhanced Interactive Python.\n?         -&gt; Introduction and overview of IPython's features.\n%quickref -&gt; Quick reference.\nhelp      -&gt; Python's own help system.\nobject?   -&gt; Details about 'object', use 'object??' for extra details.\n<\/pre>\n<h2>UNIX\u30b3\u30de\u30f3\u30c9\u30c4\u30fc\u30eb<\/h2>\n<p>\u65e5\u5e38\u306eUNIX\u30b3\u30de\u30f3\u30c9\u306e\u5b9f\u884c\u306f\u982d\u306b!\u3092\u4ed8\u3051\u308c\u3070\u5b9f\u884c\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>In [10]: !ps\nPID TTY TIME CMD\n11110 pts\/0 00:00:00 bash\n11219 pts\/0 00:00:00 ipython\n11273 pts\/0 00:00:00 ps\n<\/pre>\n<pre>In [11]: !ls \/bin\narch cut dmesg fgrep ipcalc ls mv readlink setserial tracepath\nusleep awk dash dnsdomainname find iptables-xml lsblk nano red sh\ntracepath6 vi\n(snip)\nmktemp ping6 rvi sync uname chown dbus-uuidgen env gunzip ln\nmore ps rview tar unicode_start cp dd ex gzip loadkeys\nmount pwd sed taskset unicode_stop cpio df false hostname login\nmountpoint raw setfont touch unlink\n<\/pre>\n<p>\u3082\u3061\u308d\u3093\u30d1\u30a4\u30d7\u3082\u4f7f\u3048\u307e\u3059<\/p>\n<pre>In [13]: !ss | less\n<\/pre>\n<h2>python\u3089\u3057\u304f\u4f7f\u3046<\/h2>\n<p>\u305b\u3063\u304b\u304fpython\u306e\u51e6\u7406\u7cfb\u306e\u4e0a\u306b\u3044\u308b\u306e\u3067!\u3092\u3064\u3051\u3066\u30b3\u30de\u30f3\u30c9\u3092\u305f\u305f\u304f\u3060\u3051\u3060\u3068\u3001\u305f\u3060\u9762\u5012\u306b\u306a\u3063\u305f\u3060\u3051\u306a\u306e\u3067python\u3089\u3057\u3044\u4f7f\u3044\u65b9\u3092\u3057\u307e\u3059\u3002<\/p>\n<pre>In [17]: net = !ss\n<\/pre>\n<p>ss\u306e\u5b9f\u884c\u7d50\u679c\u3092\u5909\u6570\u306b\u5165\u308c\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002\u5909\u6570\u306f\u305d\u306e\u307e\u307e\u5165\u529b\u3059\u308b\u3068\u30aa\u30d6\u30b8\u30a7\u30af\u30c8\u306e\u5185\u5bb9\u3092\u8868\u793a\u3057\u307e\u3059\u3002<\/p>\n<pre>In [18]: net\nOut[18]:\n['Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port ',\n'u_str ESTAB 0 0 * 7622 * 7621 ',\n'u_str ESTAB 0 0 * 7642 * 7643 ',\n'u_str ESTAB 0 0 * 54038 * 54037 ',\n'u_str ESTAB 0 0 * 6794 * 6793 ',\n'u_str ESTAB 0 0 * 7594 * 7595 ',\n'u_str ESTAB 0 0 * 7637 * 7636 ',\n'u_str ESTAB 0 0 * 7586 * 7587 ',\n'u_str ESTAB 0 0 * 7615 * 7616 ',\n'u_str ESTAB 0 0 * 7619 * 7618 ',\n'u_str ESTAB 0 0 * 7633 * 7634 ',\n'u_str ESTAB 0 0 * 7583 * 7584 ',\n'u_str ESTAB 0 0 * 7607 * 7606 ',\n'u_str ESTAB 0 0 * 7598 * 7597 ',\n'u_str ESTAB 0 0 \/var\/run\/dbus\/system_bus_socket 6800 * 6799 ',\n'u_str ESTAB 0 0 * 7625 * 7624 ',\n'u_str ESTAB 0 0 * 7646 * 7645 ',\n'tcp ESTAB 0 80 172.31.6.147:ssh 110.4.174.177:52024 ']\n\nIn [19]:\n<\/pre>\n<p>\u753b\u9762\u304b\u3089\u3042\u3075\u308c\u3066\u56f0\u308b\u3068\u304d\u306b\u306f\u30da\u30fc\u30b8\u30e3\u3068\u3057\u3066page\u30b3\u30de\u30f3\u30c9\u304c\u4f7f\u3048\u307e\u3059\u3002<\/p>\n<pre>In [20]: page net\n['Netid State Recv-Q Send-Q Local Address:Port Peer Address:Port ',\n'u_str ESTAB 0 0 * 7622 * 7621 ',\n'u_str ESTAB 0 0 * 7642 * 7643 ',\n'u_str ESTAB 0 0 * 6793 * 6794 ',\n\uff08snip\uff09\n'u_str ESTAB 0 0 * 7624 * 7625 ',\n:\n<\/pre>\n<p>\u7d50\u679c\u306fpython\u306e\u914d\u5217\u306a\u306e\u3067\u914d\u5217\u306b\u5bfe\u3057\u3066\u306e\u64cd\u4f5c\u304c\u3067\u304d\u307e\u3059<\/p>\n<pre>In [24]: process = !ps -axg\n\nIn [25]: process.grep('httpd')\nOut[25]:\n[' 1556 ? Ss 0:17 \/usr\/sbin\/httpd',\n' 1578 ? S 0:00 \/usr\/sbin\/httpd',\n' 1579 ? S 0:00 \/usr\/sbin\/httpd',\n' 1580 ? S 0:00 \/usr\/sbin\/httpd',\n' 1581 ? S 0:00 \/usr\/sbin\/httpd',\n' 1582 ? S 0:00 \/usr\/sbin\/httpd',\n' 2584 ? S 0:00 \/usr\/sbin\/httpd',\n' 2585 ? S 0:00 \/usr\/sbin\/httpd',\n' 2586 ? S 0:00 \/usr\/sbin\/httpd']\n\nIn [26]:\n<\/pre>\n<h2>notebook\u30a4\u30f3\u30bf\u30d5\u30a7\u30fc\u30b9<\/h2>\n<pre>$ ipython notebook\n<\/pre>\n<p>\u3067\u8d77\u52d5\u3059\u308b\u3068\u7acb\u6d3e\u306aWeb\u30a4\u30f3\u30bf\u30d5\u30a7\u30fc\u30b9\u304c\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f\u30d6\u30e9\u30a6\u30b6\u3082\u8d77\u52d5\u3057\u307e\u3059\u306e\u3067\u3001\u9069\u5b9c<tt>--no-browser<\/tt>\u3092\u3064\u3051\u3066\u8d77\u52d5\u3059\u308b\u3068\u826f\u3044\u3067\u3059\u3002<\/p>\n<pre>$ ipython notebook --no-browser\n<\/pre>\n<p>\u307e\u305f\u30dd\u30fc\u30c8\u306f8888\u3067\u8d77\u52d5\u3057\u307e\u3059\u306e\u3067\u3001\u3053\u3061\u3089\u3082\u56f0\u308b\u3063\u3066\u5834\u5408\u306b\u306f<\/p>\n<pre>$ ipython notebook --no-browser --port=8080\n<\/pre>\n<p>\u306a\u3069\u3067\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>tornodo\u3092\u3064\u304b\u3063\u305f\u3059\u3054\u304f\u304d\u308c\u3044\u306a\u30a4\u30f3\u30bf\u30d5\u30a7\u30fc\u30b9\u3067\u3059\u3002<\/p>\n<h2>notebook\u3092\u30ea\u30e2\u30fc\u30c8\u30b5\u30fc\u30d0\u3068\u3057\u3066\u30bb\u30c3\u30c8\u30a2\u30c3\u30d7<\/h2>\n<p>\u30c7\u30d5\u30a9\u30eb\u30c8\u3067\u306f127.0.0.1\u306bbind\u3057\u3066\u8d77\u52d5\u3057\u3066\u3044\u308b\u305f\u3081\u30ed\u30fc\u30ab\u30eb\u304b\u3089\u306e\u307f\u5229\u7528\u304c\u3067\u304d\u307e\u3059\u3002\u5916\u90e8\u304b\u3089\u5229\u7528\u3059\u308b\u306b\u306f\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u3067\u8a2d\u5b9a\u304c\u5fc5\u8981\u3068\u306a\u308a\u307e\u3059\u3002<br \/>\n\u30aa\u30d5\u30a3\u30b7\u30e3\u30eb\u306e\u30c9\u30ad\u30e5\u30e1\u30f3\u30c8\u3092\u53c2\u7167\u3057\u3066\u3044\u305f\u3060\u3051\u3070\u5bb9\u6613\u306a\u5185\u5bb9\u3067\u3059\u304c\u624b\u9806\u3092\u793a\u3057\u307e\u3059\u3002<\/p>\n<h3>\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u751f\u6210\u3057\u307e\u3059<\/h3>\n<p>ipython\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u4e2d\u3067\u30d1\u30b9\u30ef\u30fc\u30c9\u751f\u6210\u306e\u30c4\u30fc\u30eb\u304c\u7528\u610f\u3055\u308c\u3066\u3044\u307e\u3059\u306e\u3067\u5229\u7528\u3057\u307e\u3057\u3087\u3046\u3002<\/p>\n<pre>In [1]: from IPython.lib import passwd\n\nIn [2]: passwd()\nEnter password:\nVerify password:\nOut[2]: 'sha1:046e2277e775:7fbd40dd1514280715e17c48b2e3a86258cde63c'\n<\/pre>\n<p>\u51fa\u529b\u7d50\u679c\u3092\u898b\u3066\u306e\u901a\u308asha1\u306e\u30cf\u30c3\u30b7\u30e5\u3092\u751f\u6210\u3059\u308b\u3060\u3051\u306a\u306e\u3067\u3001\u540c\u3058\u3088\u3046\u306bsha1\u304c\u751f\u6210\u3067\u304d\u308c\u3070\u4ed6\u306e\u30c4\u30fc\u30eb\u3067\u3082\u554f\u984c\u306a\u3044\u304b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h3>\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u306b\u8a18\u8f09\u3057\u307e\u3059<\/h3>\n<p>\u30ea\u30e2\u30fc\u30c8\u7528\u306e\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u3092\u4f5c\u6210\u3057\u3066\u304a\u304d\u307e\u3059<\/p>\n<pre>\n$ ipython profile create nbserver\n<\/pre>\n<p>\u3053\u308c\u3067<tt>~\/.ipython\/profile_nbserver<\/tt>\u306e\u4e2d\u306bdefault\u3068\u306f\u5225\u306e\u30ea\u30e2\u30fc\u30c8\u7528\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u304c\u4f5c\u6210\u3055\u308c\u307e\u3059\u3002<br \/>\n\u3055\u3063\u305d\u304f\u3001\u30ea\u30e2\u30fc\u30c8\u30b5\u30fc\u30d0\u7528\u306e\u30b3\u30f3\u30d5\u30a3\u30b0\u3092\u7de8\u96c6\u3057\u307e\u3059\u3002<\/p>\n<pre>\n$ vim ~\/.ipython\/profile_nbserver\/ipython_notebook_config.py\n<\/pre>\n<p>\u8a18\u8f09\u7b87\u6240\u306f<\/p>\n<ul>\n<li>\u30d0\u30a4\u30f3\u30c9\u3059\u308bIP\u30a2\u30c9\u30ec\u30b9\u3092\u5168\u90e8<\/li>\n<li>\u30d1\u30b9\u30ef\u30fc\u30c9\u3092\u6307\u5b9a<\/li>\n<li>\u8a3c\u660e\u66f8\u3092\u6307\u5b9a<\/li>\n<li>\u30d6\u30e9\u30a6\u30b6\u3092\u958b\u304b\u306a\u3044<\/li>\n<\/ul>\n<p>\u3068\u306a\u308a\u307e\u3059\u3002<br \/>\n\u306a\u304a\u3001\u4eca\u56de\u306f\u8a3c\u660e\u66f8\u306e\u6307\u5b9a\u306f\u7121\u3057\u3067\u8a2d\u5b9a\u3057\u307e\u3059\u3002<\/p>\n<h4>bind\u30a2\u30c9\u30ec\u30b9\u3092\u6307\u5b9a\u3057\u307e\u3059\u3002<\/h4>\n<pre>\n# The IP address the notebook server will listen on.\n# c.NotebookApp.ip = '127.0.0.1'\nc.NotebookApp.ip = '*'\n<\/pre>\n<h4>\u30d1\u30b9\u30ef\u30fc\u30c9\u306e\u8a2d\u5b9a<\/h4>\n<p>\u5148\u306e\u624b\u9806\u3067\u53d6\u5f97\u3057\u305f\u30cf\u30c3\u30b7\u30e5\u3092\u8a18\u8f09\u3057\u307e\u3059\u3002<\/p>\n<pre>\n# Hashed password to use for web authentication.\n#\n# To generate, type in a python\/IPython shell:\n#\n# from IPython.lib import passwd; passwd()\n#\n# The string should be of the form type:salt:hashed-password.\n# c.NotebookApp.password = u''\nc.NotebookApp.password = u'sha1:046e2277e775:7fbd40dd1514280715e17c48b2e3a86258cde63c'\n<\/pre>\n<p>\u30d6\u30e9\u30a6\u30b6\u3092\u958b\u304b\u306a\u3044\u7528\u306b\u3057\u307e\u3059\u3002<\/p>\n<pre>\n# c.NotebookApp.open_browser = True\nc.NotebookApp.open_browser = False\n<\/pre>\n<h3>\u8d77\u52d5<\/h3>\n<p>\u8a18\u8f09\u3057\u305f\u30d7\u30ed\u30d5\u30a1\u30a4\u30eb\u3092\u5229\u7528\u3057\u3066\u8d77\u52d5\u3057\u307e\u3059\u3002<\/p>\n<pre>\nipython notebook --profile=nbserver\n<\/pre>\n<p>\u30d6\u30e9\u30a6\u30b6\u304b\u3089<br \/>\n<tt>http:\/\/IP\u30a2\u30c9\u30ec\u30b9:8888\/<\/tt><br \/>\n\u306e\u3088\u3046\u306a\u5f62\u3067\u30a2\u30af\u30bb\u30b9\u3057\u3066\u3001\u30ed\u30b0\u30a4\u30f3\u5f8c\u306b\u753b\u9762\u304c\u3067\u308c\u3070\u6210\u529f\u3067\u3059\u3002<br \/>\n\u203bAWS\u306e\u5834\u5408\u306b\u306f\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u30b0\u30eb\u30fc\u30d7\u306b\u59a5\u5f53\u306a\u30a2\u30c9\u30ec\u30b9\u3092\u8a31\u53ef\u3057\u307e\u3057\u3087\u3046\u3002<br \/>\n<div id=\"attachment_116\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/2014-07-03_122930.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-116\" src=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/2014-07-03_122930-300x187.png\" alt=\"ipython:notebook\" width=\"300\" height=\"187\" class=\"size-medium wp-image-116\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/2014-07-03_122930-300x187.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/2014-07-03_122930.png 798w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-116\" class=\"wp-caption-text\">notebook\u8d77\u52d5\u753b\u9762<\/p><\/div>\n\u30bf\u30d6\u306b\u3088\u308b\u30b3\u30fc\u30c9\u306e\u88dc\u5b8c\u3082\u304d\u304d\u307e\u3059\u3057\u3001\u30bb\u30fc\u30d6\u3082\u3067\u304d\u307e\u3059\u3002<br \/>\n<div id=\"attachment_117\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/2014-07-03_123751.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-117\" src=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/2014-07-03_123751-300x187.png\" alt=\"ipython\" width=\"300\" height=\"187\" class=\"size-medium wp-image-117\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/2014-07-03_123751-300x187.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/2014-07-03_123751.png 798w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-117\" class=\"wp-caption-text\">\u30bf\u30d6\u88dc\u5b8c\u5bfe\u5fdc<\/p><\/div>\n\u66f8\u3044\u305f\u30b3\u30fc\u30c9\u306f\u5b9f\u884c\u30dc\u30bf\u30f3\u3067\u78ba\u8a8d\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u307e\u3059\u3002<br \/>\n<div id=\"attachment_114\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/2014-07-03_124105.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-114\" src=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/2014-07-03_124105-300x199.png\" alt=\"\u5b9f\u884c\u30dc\u30bf\u30f3\" width=\"300\" height=\"199\" class=\"size-medium wp-image-114\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/2014-07-03_124105-300x199.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/2014-07-03_124105-220x146.png 220w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/2014-07-03_124105.png 762w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-114\" class=\"wp-caption-text\">\u5b9f\u884c\u30dc\u30bf\u30f3<\/p><\/div>\n<h4>\u30b5\u30fc\u30d0\u5185\u306e\u30a2\u30af\u30bb\u30b9\u30ed\u30b0\u3092\u30d1\u30fc\u30b9\u3057\u3066\u8868\u793a\u3057\u3066\u307f\u308b<\/h4>\n<p>https:\/\/code.google.com\/p\/apachelog\/<br \/>\n\u306b\u3066\u914d\u5e03\u3057\u3066\u3044\u308bapachelog\u30e2\u30b8\u30e5\u30fc\u30eb\u3092\u7528\u3044\u3066\u30b5\u30fc\u30d0\u5185\u306eApacheWeb\u30b5\u30fc\u30d0\u306e\u30ed\u30b0\u3092\u30d1\u30fc\u30b9\u3057\u3066\u307f\u307e\u3059\u3002<br \/>\n\u3053\u306e\u30e2\u30b8\u30e5\u30fc\u30eb\u306e\u4fbf\u5229\u306a\u3068\u3053\u308d\u306fhttpd.conf\u3067\u8a18\u8f09\u3057\u3066\u3044\u308b\u30ed\u30b0\u8a18\u8ff0\u5b50\u3092\u305d\u306e\u307e\u307e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u3068\u3057\u3066\u6307\u5b9a\u3067\u304d\u308b\u3068\u3053\u308d\u3067\u3059\u3002\u305d\u306e\u305f\u3081access_log\u306e\u30d5\u30a9\u30fc\u30de\u30c3\u30c8\u304c\u7570\u306a\u308b\u30b5\u30fc\u30d0\u3078\u306e\u5bfe\u5fdc\u3082\u5bb9\u6613\u306b\u5b9f\u65bd\u3067\u304d\u307e\u3059\u3002<\/p>\n<pre>\nimport apachelog, sys\n# Format copied and pasted from Apache conf - use raw string + single quotes\nformat = r'\"%h %l %u %t \\\"%r\\\" %&gt;s %b \\\"%{Referer}i\\\" \\\"%{User-Agent}i\\\"\"'\np = apachelog.parser(format)\nfor line in open('\/var\/log\/httpd\/access_log-20131118'):\n    try:\n        data = p.parse(line)\n        print data['%r']\n    except:\n        sys.stderr.write(\"Unable to parse %s\" % line)\n<\/pre>\n<p>\u307b\u307cipython\u3067help\u3067\u8868\u793a\u3055\u308c\u308b\u5185\u5bb9\u305d\u306e\u307e\u307e\u3067\u3059\u304c\u30b3\u30fc\u30c9\u3092\u7de8\u96c6\u3057\u306a\u304c\u3089\u3001\u3059\u3050\u306b\u7d50\u679c\u304c\u5f97\u3089\u308c\u308b\u611f\u899a\u306f\u697d\u3057\u3044\u3068\u601d\u3044\u307e\u3059\u3002\u3044\u304b\u304c\u3067\u3057\u3087\u3046\u304b\u3002<\/p>\n<p>\u53c2\u8003\uff1ahelp\u306e\u4f7f\u3044\u65b9<\/p>\n<pre>\nIn [2]: import apachelog\n\nIn [3]: help(apachelog)\n<\/pre>\n<div id=\"attachment_115\" style=\"width: 310px\" class=\"wp-caption alignnone\"><a href=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/2014-07-03_133821.png\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-115\" src=\"http:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/2014-07-03_133821-300x265.png\" alt=\"\u5b9f\u884c\u4f8b\" width=\"300\" height=\"265\" class=\"size-medium wp-image-115\" srcset=\"https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/2014-07-03_133821-300x265.png 300w, https:\/\/www.skyarch.net\/blog\/wp-content\/uploads\/2014\/07\/2014-07-03_133821.png 858w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><p id=\"caption-attachment-115\" class=\"wp-caption-text\">\u5b9f\u884c\u4f8b<\/p><\/div>\n\u306a\u304a\u3001\u30b5\u30fc\u30d0\u5185\u3067\u306e\u5b9f\u884c\u74b0\u5883\u305d\u306e\u3082\u306e\u306a\u306e\u3067\u3001\u30ea\u30e2\u30fc\u30c8\u30b5\u30fc\u30d0\u306e\u5834\u5408\u306b\u306f\u7279\u306b\u30bb\u30ad\u30e5\u30ea\u30c6\u30a3\u306b\u306f\u304a\u6c17\u3092\u3064\u3051\u304f\u3060\u3055\u3044\u3002<br \/>\n<br \/>\n\u30ea\u30e2\u30fc\u30c8\u30b5\u30fc\u30d0\u306e\u30b7\u30b9\u30c6\u30e0\u306e\u60c5\u5831\u3092\u53d6\u308a\u306a\u304c\u3089\u96c6\u8a08\u3092\u884c\u3046\u306a\u3069\u53ef\u80fd\u6027\u306f\u3042\u308a\u305d\u3046\u3067\u3059\u306d\u3002<\/p>\n<h2>\u30ea\u30f3\u30af<\/h2>\n<p>1\u6b21\u914d\u5e03\u5148\u3067\u3059\u3002<br \/>\n<a href=\"http:\/\/ipython.org\/\">ipython.org<\/a><br \/>\n\u5c11\u3057\u53e4\u3044\u672c\u3067\u3059\u304c\u3001\u5229\u7528\u4f8b\u306b\u3064\u3044\u3066\u66f8\u304b\u308c\u3066\u3044\u308b\u30aa\u30e9\u30a4\u30ea\u30fc\u306e\u66f8\u7c4d\u3067\u3059\u3002<br \/>\n<a href=\"http:\/\/shop.oreilly.com\/product\/9780596515829.do\">Python for Unix and Linux System Administration<\/a><\/p>\n<p>\u4e0b\u8a18\u306f\u5546\u7528\u7248\u306e\u30b5\u30fc\u30d3\u30b9\u3092\u5c55\u958b\u3057\u3066\u3044\u308b\u30b5\u30a4\u30c8\u3067\u3059\u3002<br \/>\nWindows\u3067\u306e\u5229\u7528\u306f\u3053\u3061\u3089\u306eanaconda\u304c\u4fbf\u5229\u3060\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n<a href=\"http:\/\/continuum.io\/\">continuum.io<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u306f\u3058\u3081\u306b \u6709\u540d\u306a\u30c4\u30fc\u30eb\u306a\u306e\u3067ipython\u306b\u3064\u3044\u3066\u3044\u307e\u3055\u3089\u8aac\u660e\u3057\u306a\u304f\u3068\u3082\u4f7f\u3044\u8fbc\u3093\u3067\u3044\u308b\u65b9\u3082\u591a\u3044\u3068\u601d\u3044\u307e\u3059\u304c http:\/\/ipython.org\/ \u306b\u3066\u914d\u5e03\u3057\u3066\u3044\u308b\u3001\u30a4\u30f3\u30bf\u30e9\u30af\u30c6\u30a3\u30d6shell\u3068\u3057\u3066\u3082\u4f7f\u3048\u308bpython\u3067&#8230;<\/p>\n","protected":false},"author":3,"featured_media":121,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_locale":"ja","_original_post":"http:\/\/www.skyarch.net\/blog\/?p=106","footnotes":""},"categories":[9],"tags":[65,36],"class_list":{"0":"post-106","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-dev","8":"tag-python","9":"tag-tips","10":"ja"},"aioseo_notices":[],"_links":{"self":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/106","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/comments?post=106"}],"version-history":[{"count":16,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/106\/revisions"}],"predecessor-version":[{"id":21112,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/posts\/106\/revisions\/21112"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media\/121"}],"wp:attachment":[{"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/media?parent=106"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/categories?post=106"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.skyarch.net\/blog\/wp-json\/wp\/v2\/tags?post=106"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}