{"id":127,"date":"2014-06-25T14:42:09","date_gmt":"2014-06-25T14:42:09","guid":{"rendered":"http:\/\/ixyzero.com\/blog\/?p=127"},"modified":"2014-06-25T14:42:09","modified_gmt":"2014-06-25T14:42:09","slug":"%e6%89%b9%e9%87%8f%e4%b8%8b%e8%bd%bdblogbus%e7%9a%84%e6%96%87%e7%ab%a0","status":"publish","type":"post","link":"https:\/\/ixyzero.com\/blog\/archives\/127.html","title":{"rendered":"\u6279\u91cf\u4e0b\u8f7dBlogbus\u7684\u6587\u7ae0"},"content":{"rendered":"<p>\u4e4b\u524d\u56e0\u4e3a\u641c\u7d22Everything\u7684\u4f7f\u7528\u6280\u5de7\u800c\u78b0\u5230\u4e86\u4e00\u4e2a\u725b\u4eba\u7684blog\uff1a<a href=\"http:\/\/just-study.blogbus.com\/\" target=\"_blank\">http:\/\/just-study.blogbus.com\/ <\/a>\u4e0d\u8fc7\u5f53\u6211\u627e\u5230\u8fd9\u4e2ablog\u7684\u65f6\u5019\u770b\u5230\u7684\u5df2\u7ecf\u662f\u201c\u535a\u5ba2\u8fc1\u79fb\u201d\u7684\u4fe1\u606f\u4e86\uff0c\u867d\u7136\u535a\u4e3b\u5df2\u7ecf\u4e0d\u7528Blogbus\u8bb0\u5f55\u800c\u662f\u8f6c\u5411GitHub\u4e86\uff0c\u4f46\u662f\u539f\u59cbblog\u91cc\u9762\u8fd8\u662f\u6709\u5f88\u591a\u503c\u5f97\u4e00\u770b\u7684\u5185\u5bb9\u7684\uff0c\u6bd4\u5982\u6211\u73b0\u5728\u60f3\u8bf4\u7684\u201c\u535a\u5ba2\u8fc1\u79fb\u201d\u8fd9\u7bc7\u6587\u7ae0\uff0c\u5185\u5bb9\u5927\u6982\u5c31\u662f\u7528bash\u6293\u53d6\u81ea\u5df1blog\u7684\u6587\u7ae0\u5b58\u4e3aHTML\u6587\u4ef6\uff0c\u65b9\u4fbf\u81ea\u5df1\u8f6c\u79fb\u5230GitHub\u4e0a\u53bb\uff0c\u4f46\u662f\u6211\u7b2c\u4e00\u6b21\u7528\u7684\u65f6\u5019\u5b58\u5728\u95ee\u9898\uff0c\u800c\u4e14\u91cc\u9762\u7528\u5230\u4e86\u4e00\u4e9b\u4e4b\u524d\u63a5\u89e6\u7684\u6bd4\u8f83\u5c11\u7684Perl\u548csed\u7528\u6cd5\uff0c\u5f53\u65f6\u6bd4\u8f83\u5934\u75bc\uff0c\u90fd\u4e0d\u60f3\u518d\u8bd5\u4e86\uff0c\u4e0d\u8fc7\u4e0b\u5348\u7761\u4e86\u4e2a\u597d\u89c9\u5fc3\u60c5\u4e0d\u9519\uff0c\u89c9\u5f97\u8fd8\u662f\u53ef\u4ee5\u518d\u5f04\u5f04\uff0c\u7136\u540e\u4ed4\u7ec6\u7684\u770b\u811a\u672c\uff0c\u540c\u65f6\u641c\u7d22\u4e0d\u61c2\u7684\u5730\u65b9\uff0c\u628ased\u7684\u7528\u6cd5\u987a\u4fbf\u4e5f\u719f\u6089\u4e86\u4e00\u904d\uff0c\u4e0d\u597d\u7684\u4e00\u70b9\u5c31\u662f\u65f6\u95f4\u82b1\u7684\u6709\u70b9\u591a\u4e86\uff0c\u672c\u60f3\u77401\u4e2a\u5c0f\u65f6\u4ee5\u5185\u628a\u6240\u6709\u7684\u5de5\u4f5c\u505a\u5b8c\uff0c\u7136\u540e\uff0c\u53c8\u5f04\u4e86\u51e0\u4e2a\u5c0f\u65f6o(\u256f\u25a1\u2570)o \u6c34\u5e73\u592a\u5dee\u4e86\uff0c\u5bf9\u81ea\u5df1\u8fc7\u4e8e\u4e50\u89c2\u81ea\u4fe1\u4e86\u2026\u2026<\/p>\n<h6>\u5148\u653e\u51fa\u6211\u540e\u6765\u4fee\u6539\u4e4b\u540e\u53ef\u7528\u7684\u811a\u672c\uff1a<\/h6>\n<pre class=\"lang:sh decode:true\">#!\/bin\/bash\n\nblog_url=\"http:\/\/just-study.blogbus.com\";\nfor i in $(seq 1 2);do\n\tfile=url_tag.$$\n\tif test $i -eq 1;then\n\t\turl=\"$blog_url\"\n\telse\n\t\turl=\"$blog_url\/index_$i.html\"\n\tfi\n\n\tcurl -m 150 -s $url | grep \"&lt;a href='http:\/\/www.blogbus.com\/just-study-logs\/\" | perl -pe 's\/.*href..(.*html).*&gt;(.*)..a&gt;.*\/$1\/g' &gt;&gt; ${file}\ndone\niCount=1\nawk '!a[$0]++' url_tag.* | wc -l\t# show counts\ncat url_tag.* | sort -u  | while read url tag;do\ncurl -m 150 -s $url | sed -n '\/postHeader\/,\/relpost\/p' | sed '$d' &gt;tmp.file\ndos2unix tmp.file\ntitle=$(cat tmp.file | sed -n '3p' | perl -pe 's\/s*&lt;[^&lt;]+&gt;\/\/g')\ndt=$(cat tmp.file | sed  -n '2p' | perl -pe 's\/..:..:..\/\/g'| perl -pe 's\/[\u5e74\u6708\u65e5]\/\/g')\n#filename=\"$dt-$tag-$title.html\"\nfilename=\"$dt--$iCount.html\"\n#sed '\/&lt;body&gt;\/r' tmp.file &gt; \"$filename\"\ncat tmp.file &gt; \"$filename\"\n((iCount++))\ndone\n\n#rm -rf tmp.file\n<\/pre>\n<h6>\u8fd8\u6709\u4e00\u4e2a\u7248\u672c\uff08\u6709\u7248\u6743\u4fe1\u606f\u7684\uff09\uff1a<\/h6>\n<pre class=\"lang:sh decode:true \">#!\/bin\/bash\n\nblog_url=\"http:\/\/just-study.blogbus.com\";\nfor i in $(seq 1 12);do\n\tfile=url_tag.$$\n\tif test $i -eq 1;then\n\t\turl=\"$blog_url\"\n\telse\n\t\turl=\"$blog_url\/index_$i.html\"\n\tfi\n\n\tcurl -m 150 -s $url | grep \"&lt;a href='http:\/\/www.blogbus.com\/just-study-logs\/\" | perl -pe 's\/.*href..(.*html).*&gt;(.*)..a&gt;.*\/$1 $2\/g' &gt;&gt; ${file}\ndone\niCount=1\ncat url_tag.* | sort -u\ncat url_tag.* | sort -u  | while read url tag;do\ncurl -m 150 -s $url | sed -n '\/postHeader\/,\/Site Meter\/p' | sed '$d' &gt;tmp.file\ndos2unix tmp.file\ntitle=$(cat tmp.file | sed -n '3p'| perl -pe 's\/s*&lt;[^&lt;]+&gt;\/\/g')\ndt=$(cat tmp.file | sed  -n '2p' | perl -pe 's\/..:..:..\/\/g'| perl -pe 's\/[\u5e74\u6708\u65e5]\/\/g')\n#filename=\"$dt-$tag-$title.html\"\nfilename=\"$dt--$iCount.html\"\ncat tmp.file &gt; \"$filename\"\n((iCount++))\ndone\n\nrm -rf tmp.file<\/pre>\n<p>\u56e0\u4e3a\u4e4b\u524d\u5728\u6293\u53d6\u7684\u65f6\u5019\u78b0\u5230\u4e86\u51e0\u4e2a\u95ee\u9898\uff1a\u5185\u5bb9\u91cd\u590d\uff08\u6211\u7528\u7684\u662fawk\u7684\u65b9\u6cd5\u53bb\u91cd\uff09\u3001dos2unix\u547d\u4ee4\u6267\u884c\u51fa\u9519\uff08\u539f\u6765\u7684\u6587\u4ef6\u547d\u540d\u867d\u7136\u76f4\u89c2\uff0c\u4f46\u662f\u56e0\u4e3a\u6587\u4ef6\u540d\u4e2d\u542b\u6709\u659c\u7ebf\u8fd9\u79cd\u7279\u6b8a\u5b57\u7b26\uff0c\u6240\u4ee5dos2unix\u547d\u4ee4\u518d\u6267\u884c\u7684\u65f6\u5019\u4f1a\u62a5\u9519\uff1aNo such file&#8230;\uff09\uff0c\u6587\u4ef6\u547d\u540d\u51fa\u9519\uff08bash\u5faa\u73af\u4e2d\u7684\u53d8\u91cf\u503c\u53d8\u5316\uff09\u7b49\u7b49\uff0c\u6240\u4ee5\u811a\u672c\u6700\u540e\u6539\u6210\u4e86\u4e0a\u9762\u7684\u6a21\u6837\uff0c\u8fd8\u6ca1\u6709\u5728HTML\u6587\u4ef6\u4e2d\u52a0\u4e0a\u539f\u4f5c\u8005\u7684\u7248\u6743\u4fe1\u606f\uff0c\u5b9e\u5728\u62b1\u6b49\uff0c\u56e0\u4e3a\u6bd5\u7adf\u559c\u6b22\u5e72\u51c0\u70b9\u7684HTML\u4ee3\u7801\uff0c\u4e4b\u524d\u7684sed\u547d\u4ee4\u6ca1\u6709\u628a\u4e00\u4e9b\u6ca1\u7528\u7684HTML\u4ee3\u7801\u53bb\u9664\uff0c\u6240\u4ee5\u6211\u5c31\u6539\u6210\u8fd9\u6837\u4e86\uff0c\u5176\u5b9e\u4e5f\u53ef\u4ee5\u5728\u6bcf\u4e2a\u6587\u4ef6\u7684\u6700\u540e\u7528cat\/echo\u6dfb\u52a0\u4e00\u6bb5\u4f5c\u8005\u4fe1\u606f\uff0c\u5f85\u4f1a\u81ea\u5df1\u52a0\u4e0a\u53bb\u3002<\/p>\n<h6>\u53c2\u8003\u94fe\u63a5\uff1a<\/h6>\n<ul>\n<li><a href=\"http:\/\/www.blogbus.com\/just-study-logs\/224818094.html\" target=\"_blank\">\u535a\u5ba2\u8fc1\u79fb &#8211; Keep It Simple,Stupid! &#8211; \u535a\u5ba2\u5927\u5df4<\/a><\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p>\u4e4b\u524d\u56e0\u4e3a\u641c\u7d22Everything\u7684\u4f7f\u7528\u6280\u5de7\u800c\u78b0\u5230\u4e86\u4e00\u4e2a\u725b\u4eba\u7684blog\uff1ahttp:\/\/just-study.bl [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11,7,12],"tags":[74,83,84,85,78],"class_list":["post-127","post","type-post","status-publish","format-standard","hentry","category-linux","category-programing","category-tools","tag-awk","tag-bash","tag-curl","tag-perl","tag-sed"],"views":3131,"_links":{"self":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/127","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/comments?post=127"}],"version-history":[{"count":0,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/posts\/127\/revisions"}],"wp:attachment":[{"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/media?parent=127"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/categories?post=127"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ixyzero.com\/blog\/wp-json\/wp\/v2\/tags?post=127"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}