{"id":1919,"date":"2012-08-14T21:47:01","date_gmt":"2012-08-14T13:47:01","guid":{"rendered":"https:\/\/kyle.ai\/blog\/?p=1919"},"modified":"2013-11-17T11:06:58","modified_gmt":"2013-11-17T03:06:58","slug":"%e6%8a%8a%e5%8d%9a%e5%ae%a2%e4%bb%8e%e7%99%be%e5%ba%a6%e8%bf%81%e7%a7%bb%e4%ba%86%e8%bf%87%e6%9d%a5","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/1919.html","title":{"rendered":"\u628a\u535a\u5ba2\u4ece\u767e\u5ea6\u8fc1\u79fb\u4e86\u8fc7\u6765"},"content":{"rendered":"<p>\u4e0a\u5468\u672b\u82b1\u4e86\u4e24\u5929\u65f6\u95f4\uff0c\u7ec8\u4e8e\u628a\u535a\u5ba2\u8fc1\u79fb\u4e86\u8fc7\u6765\uff0c\u6240\u6709\u6587\u7ae0\u4e0e\u56fe\u7247\u90fd\u5b8c\u6574\u5730\u4fdd\u7559\u5728\u65b0\u535a\u5ba2\u4e2d\u3002<\/p>\n<p>\u5176\u5b9e\u5f88\u65e9\u5c31\u6709\u628a\u535a\u5ba2\u8f6c\u6210\u72ec\u95e8\u535a\u5ba2\u7684\u60f3\u6cd5\uff0c\u4e00\u76f4\u62d6\u6ca1\u5b9e\u73b0\u3002\u6700\u8fd1\u6b63\u597d\u8d81\u767e\u5ea6\u7a7a\u95f4\u5347\u7ea7\uff0c\u6765\u4e86\u60c5\u7eea\uff0c\u7d22\u6027\u4e00\u4e0b\u5b50\u6362\u4e86\u8fc7\u6765\u3002\u5bf9\u4e86\u767e\u5ea6\u7a7a\u95f4\uff0c\u7528\u4e86\u56db\u5e74\u4e86\uff0c\u611f\u60c5\u4e5f\u975e\u5e38\u6df1\uff0c\u4f46\u662f\u5b83\u6709\u51e0\u4e2a\u660e\u663e\u7684\u7f3a\u70b9\uff0c\u8ba9\u6211\u4e00\u76f4\u803f\u803f\u4e8e\u6000\u3002\u9996\u5148\u5c31\u662f\u5199\u6587\u7ae0\u7684\u65f6\u5019\uff0c\u7279\u522b\u662f\u5199\u6280\u672f\u6027\u7684\u6587\u7ae0\uff0c\u5e16\u4ee3\u7801\u6ca1\u6709\u683c\u5f0f\u5316\u4ee3\u7801\u7684\u529f\u80fd\uff0c\u5bfc\u81f4\u5e16\u51fa\u6765\u7684\u4ee3\u7801\u683c\u5f0f\u975e\u5e38\u4e71\uff0c\u5f88\u96be\u770b\u3002\u800c\u4e14\u7f16\u8f91\u5668\u529f\u80fd\u4e5f\u6bd4\u8f83\u5f31\uff0c\u6ca1\u529e\u6cd5\u5b9a\u5236\u3002\u8fd8\u6709\u7531\u4e8e\u4f17\u6240\u5468\u77e5\u7684\u539f\u56e0\uff0c\u6211\u53d1\u5e03\u7684\u5f88\u591a\u6587\u7ae0\u65f6\u4e0d\u65f6\u4f1a\u88ab\u548c\u8c10\u6389\u3002\u524d\u4e24\u5929\u6574\u7406\u535a\u5ba2\u6587\u7ae0\u7684\u65f6\u5019\uff0c\u53d1\u73b0\u4e00\u5171\u6389\u4e86\u4e00\u767e\u591a\u7bc7\u6587\u7ae0\uff0c\u53ef\u6076\u554a\u3002\u4e0d\u8fc7\u8fd8\u597d\u767e\u5ea6\u5b98\u65b9\u63d0\u4f9b\u4e86\u4e00\u4e2a\u5bfc\u51fa\u6240\u6709\u6587\u7ae0\u7684\u529f\u80fd\uff0c\u6240\u4ee5\u624d\u5f88\u5bb9\u6613\u628a\u6240\u6709\u6587\u7ae0\u8fc1\u79fb\u8fc7\u6765\u3002\u8fd8\u6709\u767e\u5ea6\u7684\u56fe\u7247\u4e0a\u4f20\u529f\u80fd\uff0c\u7b80\u76f4\u5f31\u7206\u4e86\uff0c\u4e0a\u4f20\u7684\u65f6\u5019\u6781\u4e0d\u7a33\u5b9a\uff0c\u901f\u5ea6\u4e5f\u4e0d\u5feb\uff0c\u800c\u4e14\u8fd8\u9650\u5236\u5927\u5c0f\u4e3a500K\uff0c\u8d85\u8fc7500K\u5b83\u5f3a\u5236\u6027\u538b\u7f29\u4f60\u7684\u56fe\u7247\uff0c\u5f53\u7136\u538b\u7f29\u540e\u7684\u56fe\u7247\u7b80\u76f4\u4e0d\u80fd\u770b\u3002\u6240\u4ee5\u6211\u53d1\u56fe\u7247\u7684\u65f6\u5019\u8fd8\u4f1a\u591a\u4e00\u9053\u5de5\u5e8f\uff0c\u5c31\u662f\u68c0\u67e5\u5927\u5c0f\uff0c\u5982\u679c\u53d1\u73b0\u8d85\u8fc7\u4e86500K\uff0c\u5c31\u7528convert\u547d\u4ee4\u538b\u7f29\u4e00\u4e0b\u56fe\u7247\u3002\u5728\u53d1\u65b0\u6587\u7ae0\u7684\u65f6\u5019\uff0c\u5b83\u8fd8\u4f1a\u5bf9\u6587\u7ae0\u5185\u5bb9\u8fdb\u884c\u5173\u952e\u8bcd\u68c0\u67e5\uff0c\u53d1\u73b0\u5728\u654f\u611f\u8bcd\uff0c\u5c31\u4e0d\u8ba9\u53d1\u5e03\u3002<\/p>\n<p><a href=\"https:\/\/kyle.ai\/blog\/wp-content\/uploads\/2012\/08\/0813001.jpg\"><img loading=\"lazy\" decoding=\"async\" title=\"0813001\" src=\"https:\/\/kyle.ai\/blog\/wp-content\/uploads\/2012\/08\/0813001.jpg\" alt=\"\" width=\"529\" height=\"348\" \/><\/a><\/p>\n<p>\u5bf9\u6b64\u6211\u8fd8\u4e13\u95e8\u5199\u4e86\u4e00\u4e2apython\u811a\u672c\uff0c\u4e13\u95e8\u5bf9\u5185\u5bb9\u8fdb\u884c\u654f\u611f\u8bcd\u68c0\u67e5\uff0c\u6211\u4e4b\u524d\u7684\u6587\u7ae0\u6709\u8bb2\u8fc7\u3002\u4f46\u662f\u6709\u7684\u654f\u611f\u8bcd\uff0c\u5e76\u4e0d\u5728\u6211\u7684\u6536\u5f55\u8303\u56f4\u4e4b\u5185\uff0c \u8fd9\u65f6\u5019\u5c31\u91c7\u7528\u6bd4\u8f83\u7b28\u7684\u529e\u6cd5\u201c\u4e8c\u5206\u6cd5\u201d\u6765\u627e\u654f\u611f\u8bcd\uff0c\u5c31\u662f\u4e00\u6bb5\u4e00\u6bb5\u5730\u5220\u9664\uff0c\u770b\u5220\u9664\u5230\u54ea\u91cc\u7684\u65f6\u5019\u5c31\u80fd\u53d1\u8868\u6210\u529f\uff0c\u90a3\u4e48\u8bf4\u660e\u5173\u952e\u8bcd\u5c31\u5728\u90a3\u4e00\u6bb5\u91cc\u9762\uff0c\u9010\u4e00\u7f29\u5c0f\u8303\u56f4\uff0c\u76f4\u5230\u627e\u51fa\u654f\u611f\u8bcd\u3002\u6709\u65f6\u5019\u5c31\u4e3a\u8fd9\u4e00\u70b9\u5c31\u6298\u817e\u597d\u957f\u65f6\u95f4\u624d\u80fd\u53d1\u8868\u6210\u529f\uff0c\u771f\u662f\u86cb\u75bc\u3002\u6700\u540e\u5bfc\u706b\u7d22\u5c31\u662f\u767e\u5ea6\u7a7a\u95f4\u5373\u5c06\u8fdb\u884c\u7684\u5347\u7ea7\uff0c\u628a\u4e00\u4e2a\u535a\u5ba2\u6027\u8d28\u7684\u7cfb\u7edf\u6d3b\u751f\u751f\u5730\u53d8\u6210\u4e86\u793e\u4ea4\u5316\u7684\u5de5\u5177\uff0c\u7c7b\u4f3c\u70b9\u70b9\u7f51\u7684\u90a3\u79cd\uff0c\u975e\u5e38\u4e0d\u723d\uff0c\u627e\u4e0d\u5230\u90a3\u79cd\u4e2a\u4eba\u9886\u5730\u7684\u611f\u89c9\u4e86\u3002\u8fd8\u6709\u5c31\u662f\u5347\u7ea7\u7684\u8fc7\u7a0b\u4e2d\uff0c\u53c8\u628a\u6211\u7684\u56fe\u7247\u4ec0\u4e48\u7684\u641e\u4e22\u4e86\u3002\u767e\u5ea6\u6bcf\u6b21\u5347\u7ea7\u90fd\u4f1a\u51fa\u7ea7\u8fd9\u79cd\u6280\u672f\u95ee\u9898\uff0c\u4e0a\u4e00\u6b21\u4e22\u4e86\u6211\u597d\u591a\u6587\u7ae0\uff0c\u521a\u53d1\u7684\u5c31\u83ab\u540d\u5176\u5999\u5730\u4e0d\u89c1\u4e86\uff0c\u5347\u7ea7\u5b8c\u540e\u624d\u6062\u590d\u56de\u6765\u3002<\/p>\n<p>\u6362\u535a\u5ba2\u8fd8\u6709\u4e00\u4e2a\u597d\u5904\uff0c\u5c31\u662f\u6709\u4e86\u81ea\u5df1\u7684\u670d\u52a1\u5668\uff0c\u8fd9\u6837\u5f88\u591a\u4e1c\u897f\u5c31\u6709\u6761\u4ef6\u6363\u9f13\u4e86\uff0c\u81ea\u5df1\u7684\u4e00\u4e9b\u60f3\u6cd5\uff0c\u5c31\u968f\u65f6\u53ef\u4ee5\u5199\u51fa\u6765\u653e\u5728\u670d\u52a1\u5668\u4e0a\u9762\u8dd1\u3002\u867d\u7136\u53d1\u8d39\u4e86\u4e00\u4e9b\u7ecf\u6d4e\u4e0a\u7684\u4ee3\u4ef7\uff0c\u4e0d\u8fc7\u6211\u89c9\u5f97\u5c31\u957f\u8fdc\u6765\u8bf4\uff0c\u80af\u5b9a\u662f\u503c\u7684\u3002\u6709\u7684\u4e8b\u60c5\uff0c\u8fdf\u65e9\u662f\u8981\u8fc8\u51fa\u7b2c\u4e00\u6b65\uff0c\u80fd\u65e9\u5c31\u65e9\u70b9\u3002<\/p>\n<p>\u4e0a\u9762\u8bb2\u4e86\u8fc1\u79fb\u535a\u5ba2\u7684\u80cc\u666f\u4e0e\u539f\u56e0\uff0c\u4e0b\u9762\u7740\u91cd\u8bb2\u4e00\u8bb2\u8fc1\u79fb\u7684\u8fc7\u7a0b\u3002\u7531\u4e8e\u6587\u7ae0\u4e0e\u56fe\u7247\u6bd4\u8f83\u591a\uff0c\u6587\u7ae0\u6709\u5c06\u8fd12000\u7bc7\uff0c\u56fe\u72472500\u5f20\u5de6\u53f3\uff0c\u6240\u4ee5\u4e0d\u53ef\u80fd\u4eba\u5de5\u624b\u52a8\u6765\u505a\u8fd9\u4e2a\u4e8b\u60c5\u5566\u3002\u4e3a\u6b64\u6211\u5199\u4e86\u5f88\u591a\u4e2a\u811a\u672c\uff0c\u7528\u4e86\u5f88\u591a\u547d\u4ee4\u884c\u5de5\u5177\uff0c\u5982grep\/ack\uff0csed\uff0cvim\u7b49\u3002\u7531\u4e8e\u767e\u5ea6\u5b98\u65b9\u5df2\u7ecf\u63d0\u4f9b\u5b8c\u6574\u7684\u6587\u7ae0\u6253\u5305\u4e0b\u8f7d\u529f\u80fd\uff0c\u6240\u4ee5\u6587\u7ae0\u5c31\u7701\u4e8b\u4e86\uff0c\u867d\u7136\u6211\u4e5f\u5199\u8fc7\u4e0b\u8f7d\u6587\u7ae0\u7684python\u811a\u672c\uff0c\u4f46\u662f\u4e0b\u8f7d\u4e0d\u4e86\u90a3\u4e9b\u8bbe\u7f6e\u6210\u9690\u79c1\u7684\u6587\u7ae0\u3002\u57fa\u4e8e\u73b0\u6709\u7684\u6587\u7ae0\uff0c\u6211\u8fc1\u79fb\u65b9\u6848\u601d\u8def\u5982\u4e0b\uff1a<\/p>\n<p>1\u3001\u6574\u7406\u767e\u5ea6\u6253\u5305\u7684\u6587\u7ae0\uff0c\u5c06\u6587\u7ae0\u7684\u6587\u4ef6\u3001\u53d1\u8868\u65f6\u95f4\u3001\u6587\u7ae0\u540d\u6309\u4e00\u5b9a\u683c\u5f0f\u7ec4\u7ec7\u597d\uff0c\u4ee5\u4fbf\u8fdb\u884c\u540e\u5904\u7406\u3002<br \/>\n2\u3001\u83b7\u53d6\u6587\u7ae0\u5206\u7c7b\uff0c\u5bf9\u6bcf\u7bc7\u6587\u7ae0\uff0c\u4ece\u7f51\u4e0a\u62c9\u53d6\u6587\u7ae0\u7684\u6807\u9898\u4e0e\u5206\u7c7b\uff0c\u5e76\u4e0e\u7b2c\u4e00\u6b65\u4e2d\u7684\u6587\u7ae0\u540d\u8fdb\u884c\u5339\u914d\uff0c\u5c06\u6587\u7ae0\u5206\u7c7b\u52a0\u5230\u7b2c\u4e00\u6b65\u751f\u6210\u7684\u5217\u8868\u4e2d\u53bb\u3002<br \/>\n3\u3001\u5bf9\u7b2c\u4e8c\u6b65\u5904\u7406\u540e\u7684\u5217\u8868\u8fdb\u884c\u5206\u7c7b\u68c0\u67e5\uff0c\u56e0\u4e3a\u6587\u7ae0\u6807\u9898\u5339\u914d\u80af\u5b9a\u4f1a\u6709\u4e00\u4e9b\u6587\u7ae0\u5339\u914d\u4e0d\u4e0a\uff0c\u8fd8\u6709\u9690\u79c1\u7684\u6587\u7ae0\u80af\u5b9a\u5339\u914d\u4e0d\u4e0a\uff0c\u5bf9\u8fd9\u4e9b\u5355\u72ec\u8fdb\u884c\u624b\u52a8\u6dfb\u52a0\u5206\u7c7b<br \/>\n4\u3001\u5bf9\u6587\u7ae0\u5185\u5bb9\u91cc\u9762\u7684\u56fe\u7247\u94fe\u63a5\u8fdb\u884c\u5904\u7406\u3002\u5c06\u56fe\u7247\u4e0b\u8f7d\u5230\u672c\u5730\uff0c\u7136\u540e\u5c06\u94fe\u63a5\u66ff\u6362\u6210\u76f8\u5bf9\u8def\u5f84\uff08\u540e\u9762\u4f1a\u7ed3\u5408wordpress\u7cfb\u7edf\u7684\u8def\u5f84\u518d\u4e00\u6b21\u5904\u7406\uff09\u3002<br \/>\n5\u3001\u7ecf\u8fc7\u4ee5\u4e0a\u6b65\u9aa4\uff0c\u6240\u6709\u7684\u6570\u636e\u90fd\u51c6\u5907\u597d\u4e86\uff0c\u6700\u540e\u4e00\u6b65\u5c31\u662f\u5c06\u8fd9\u4e9b\u6570\u636e\u6309\u7167wordpress\u6570\u636e\u5e93\u6307\u5b9a\u7684\u683c\u5f0f\u5b58\u5230wordpress\u6570\u636e\u5e93\u4e2d\u53bb\u3002<\/p>\n<p>\u7b2c\u4e00\u6b65\uff1a<\/p>\n<p>\u4e3b\u8981\u5bf9\u6253\u5305\u4e0b\u8f7d\u597d\u7684\u7d22\u5f15\u6587\u4ef6blog_index.html\u8fdb\u884c\u5904\u7406\uff0c\u53bb\u6389\u4e0d\u5fc5\u8981\u7684\u4fe1\u606f\uff0c\u6574\u7406\u6210\u6bd4\u8f83\u89c4\u5f8b\u7684\u5217\u8868\u3002\u8fd9\u4e00\u6b65\u4e3b\u8981\u5229\u7528vim\u6765\u5b9e\u73b0\uff0c\u7528vim\u7684\u6b63\u89c4\u5339\u914d\u66ff\u6362\u529f\u80fd\u3002\u4f8b\u5982\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n:%s\/&lt;\\li&gt;\/&lt;\\\/li&gt;\\r\/g              #\u628ali\u540e\u8fdb\u884c\u6362\u884c\r\n:%s\/&lt;li class=&quot;.\\{-}href =&quot;\/\/g    #.\\{-}\u4e3avim\u7684\u975e\u8d2a\u5a6a\u5339\u914d\r\n<\/pre>\n<p>\u6309\u7167\u7c7b\u578b\u7684\u6b65\u9aa4\u540e\uff0c\u6700\u540e\u7684\u6548\u679c\u5982\u4e0b\uff1a<\/p>\n<p><a href=\"https:\/\/kyle.ai\/blog\/wp-content\/uploads\/2012\/08\/0813002.png\"><img loading=\"lazy\" decoding=\"async\" title=\"0813002\" src=\"https:\/\/kyle.ai\/blog\/wp-content\/uploads\/2012\/08\/0813002.png\" alt=\"\" width=\"670\" height=\"329\" \/><\/a><\/p>\n<p>\u7b2c\u4e8c\u6b65\uff1a<\/p>\n<p>\u4e3b\u8981\u5199\u4e86\u4e00\u4e2apython\u811a\u672c\u6765\u5b9e\u73b0\u4e0b\u8f7d\u5206\u7c7b\u4fe1\u606f getCategory.py\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n# coding=utf-8\r\nimport urllib\r\n#import os\r\nimport codecs\r\nimport thread\r\n\r\ndef GetURLS(url):\r\n    list0 = &#x5B;]\r\n    s1 = '&lt;div class=tit&gt;&lt;a href=&quot;'\r\n    content = ''\r\n    try:\r\n        content = urllib.urlopen(url).read().decode('gbk')\r\n    except:\r\n        print url\r\n    i = content.find(s1)\r\n    if(i &lt;&gt; -1):\r\n        content = content&#x5B;i+len(s1):len(content)]\r\n    while True:\r\n        i = content.find(s1)\r\n        if(i == -1):\r\n            break\r\n        content = content&#x5B;i+len(s1):len(content)]\r\n        i = content.find('&quot;')\r\n        str0 = content&#x5B;0:i]\r\n        str0 = 'http:\/\/hi.baidu.com'+str0\r\n        list0.append(str0)\r\n        content = content&#x5B;i:len(content)]\r\n    return list0\r\n\r\ndef GetContent(url):\r\n    s1 = u'title=&quot;\u67e5\u770b\u8be5\u5206\u7c7b\u4e2d\u6240\u6709\u6587\u7ae0&quot;&gt;\u7c7b\u522b\uff1a'\r\n    s2 = '&lt;\/a&gt;'\r\n    #print url\r\n    content = urllib.urlopen(url).read().decode('gbk')\r\n    #print content\r\n    i = content.find('&lt;title&gt;')+7\r\n    content = content&#x5B;i:len(content)]\r\n    j = content.find('_')\r\n    title = content&#x5B;0:j]\r\n    i = content.find(s1)\r\n    content = content&#x5B;i+len(s1):len(content)]\r\n    j = content.find(s2)\r\n    content = content&#x5B;:j]\r\n    return content, title\r\n\r\ndef ToHTML(content, name):\r\n    name = name.replace('*', '')\r\n    name = name.replace('\/', '')\r\n    name = name.replace('\\\\', '')\r\n    name = name.replace(':', '')\r\n    name = name.replace('?', '')\r\n    name = name.replace('&quot;', '')\r\n    name = name.replace('&lt;', '')\r\n    name = name.replace('&gt;', '')\r\n    name = name.replace('|', '')\r\n    name = name.replace('#', 'Sharp')\r\n    filea = codecs.open('category.txt', 'a', 'utf-8')\r\n    filea.write(name + ' | ' +content + '\\r\\n')\r\n    filea.close()\r\n\r\ndef downOne(url, sum0):\r\n    content, title = GetContent(url)\r\n    #mylock.acquire()   #\u83b7\u53d6\u540c\u6b65\u9501\r\n    #title = str(sum0)+','+title\r\n    #print title\r\n    #mylock.release()  #\u91ca\u653e\u540c\u6b65\u9501\r\n    ToHTML(content, title)\r\n    print title\r\n\r\nHiName = 'hacklzt'\r\nbaseurl = 'http:\/\/hi.baidu.com\/'+HiName+'\/blog\/index\/'\r\ni = 0#\u535a\u5ba2\u5206\u9875\r\nsum0 = 0 #\u6587\u7ae0\u603b\u6570\r\n\r\n#\u591a\u7ebf\u7a0b\u540c\u6b65\u9501\r\nmylock = thread.allocate_lock()\r\nheadurl = ''\r\nwhile True:\r\n    list0 = GetURLS(baseurl+str(i))\r\n    #print list0\r\n    if(len(list0) == 0):\r\n        break\r\n    if(list0&#x5B;0] == headurl):\r\n        break\r\n    headurl = list0&#x5B;0]\r\n    for j in list0:\r\n        sum0 = sum0+1\r\n        thread.start_new_thread(downOne,(j, sum0))\r\n        #downOne(j, sum0)\r\n    i = i+1\r\n<\/pre>\n<p>\u4e0b\u8f7d\u540e\u7684\u683c\u5f0f\u5982\u4e0b\u56fe category.txt\uff1a<\/p>\n<p><a href=\"https:\/\/kyle.ai\/blog\/wp-content\/uploads\/2012\/08\/0813003.png\"><img loading=\"lazy\" decoding=\"async\" title=\"0813003\" src=\"https:\/\/kyle.ai\/blog\/wp-content\/uploads\/2012\/08\/0813003.png\" alt=\"\" width=\"557\" height=\"310\" \/><\/a><\/p>\n<p>\u7136\u540e\u5c06\u4e0a\u9762\u7684\u7ed3\u679c\u4e0e\u4e0a\u4e00\u6b65\u7684\u5217\u8868\u8fdb\u884c\u5339\u914d\u6574\u5408\u7684python\u811a\u672c sortCategory.py\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n#!\/bin\/bash\r\n#encoding=utf-8\r\n\r\ncategorys = {}\r\ncontent = ''\r\nnocat = 0\r\nfor line in open('category.txt'):\r\n    tmp_arr = line.split('|')\r\n    categorys&#x5B;tmp_arr&#x5B;0].strip()] = tmp_arr&#x5B;1].strip()\r\nfor line in open('blog_index.html'):\r\n    tmp_arr = line.split('|')\r\n    title = tmp_arr&#x5B;2].strip()\r\n    cat = title in categorys.keys() and categorys&#x5B;title] or ''\r\n    if not title in categorys.keys():\r\n        nocat = nocat + 1\r\n    content += line.strip() + ' | ' + cat + '\\r\\n'\r\nprint content\r\nopen('index_blog-cat.html', 'w').write(content)\r\nprint 'NO\uff1a' + str(nocat)  \uff03\u6253\u5370\u4e0d\u5339\u914d\u7684\u603b\u6570\r\n<\/pre>\n<p>\u7b2c\u4e09\u6b65\uff1a<\/p>\n<p>\u68c0\u67e5\u6709\u54ea\u4e9b\u6587\u7ae0\u6ca1\u6709\u5339\u914d\u4e0a\u5206\u7c7b\uff0c\u6253\u5370\u51fa\u6765\uff0c\u540c\u6837\u4e5f\u662fpython\u811a\u672c\u6765\u5b8c\u6210 checkCategory.py\uff1a<\/p>\n<pre class=\"brush: python; title: ; notranslate\" title=\"\">\r\n#!\/bin\/bash\r\n#encoding=utf-8\r\n\r\nfor line in open('index_blog-cat.html'):\r\n    tmp_arr = line.strip().split('|')\r\n    if tmp_arr&#x5B;-1].strip() == '':\r\n        print line\r\n<\/pre>\n<p>\u5408\u5e76\u540e\u7684\u683c\u5f0f\u5982\u56fe\uff1a<\/p>\n<p><a href=\"https:\/\/kyle.ai\/blog\/wp-content\/uploads\/2012\/08\/0813004.png\"><img loading=\"lazy\" decoding=\"async\" title=\"0813004\" src=\"https:\/\/kyle.ai\/blog\/wp-content\/uploads\/2012\/08\/0813004.png\" alt=\"\" width=\"917\" height=\"396\" \/><\/a><\/p>\n<p>\u56fe\u7247\u7684\u6587\u7ae0\u987a\u5e8f\u662f\u6211\u98a0\u5012\u4e86\u7684\uff0c\u56e0\u4e3a\u540e\u63d2\u5165\u5230\u6570\u636e\u5e93\u4e2d\u65f6\uff0c\u8981\u5148\u63d2\u5165\u8001\u7684\u6587\u7ae0\uff0c\u98a0\u5012\u6587\u672c\u5185\u5bb9\u987a\u5e8f\u4e5f\u5f88\u7b80\u5355\uff0c\u4e00\u4e2a\u547d\u4ee4\u641e\u5b9a\uff1a<\/p>\n<pre class=\"brush: bash; light: true; title: ; notranslate\" title=\"\">\r\ntac index_blog-cat.html &gt; index_blog-cat-rsort.html\r\n<\/pre>\n<p>\u7b2c\u56db\u6b65\uff1a<\/p>\n<p>\u8fd9\u4e00\u6b65\u5c06\u6587\u7ae0\u5185\u5bb9\uff08\u767e\u5ea6\u6253\u5305\u91cc\u9762\u7684html\u6587\u4ef6\uff09\u4e2d\u7684\u56fe\u7247\u94fe\u63a5\u8fdb\u884c\u66ff\u6362\uff0c\u4e3b\u8981\u5229\u7528grep\u3001ack\u4e0esed\u547d\u4ee4\u63a5\u5408\u6765\u5b9e\u73b0\uff0c\u4f8b\u5982\uff1a<\/p>\n<pre class=\"brush: bash; light: true; title: ; notranslate\" title=\"\">\r\nsed -i 's\/src=&quot;pics\\\/hiphotos.baidu.com\\\/hacklzt\\\/pic\\\/item\/src=&quot;..\/wp-content\/uploads\/hibaidu\/g' blog\/*.html\r\n\uff03\u6ce8\u610f\\\u7684\u8f6c\u4e49\u4f5c\u7528\r\n<\/pre>\n<p>\u8003\u8651\u5230\u4e0d\u4ec5\u8981\u66ff\u6362\u94fe\u63a5\uff0c\u8fd8\u8981\u5c06\u56fe\u7247\u4e0b\u8f7d\u5230\u672c\u5730\uff0c\u4e8e\u662f\u5199\u4e86\u4e00\u4e2ashell\u811a\u672c\u6765\u5b8c\u6210 pics.sh\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n#\/bin\/bash\r\n#encoding=utf8\r\ngrep -o -P ' pics.url  #\u5c06\u56fe\u7247\u5730\u5740\u4fdd\u5b58\r\nwhile read line; do\r\n    fname=`echo ${line} |awk -F\/ '{print $NF}'`  #\u627e\u51fa\u56fe\u7247\u5730\u5740\u7684\u6587\u4ef6\u540d\r\n    echo ${line}'  '${fname}\r\n    regurl=${line\/\/\\\/\/\\\\\\\/}    #\u6b63\u5219\u5339\u914d\u65f6\uff0c\u5c06\/\u66ff\u6362\u6210\\\/\r\n    sed -i &quot;s\/${regurl}\/pics\\\/${fname}\/g&quot; blog\/*.html  #\u6b63\u5219\u66ff\u6362\u56fe\u7247\u5730\u5740\r\n\r\n    #echo &quot;curl -o pics\/${fname} ${line} &gt; \/dev\/null&quot;  #\u4e0b\u8f7d\u56fe\u7247\r\n    curl -o pics\/${fname} ${line} &gt; \/dev\/null  #\u4e0b\u8f7d\u56fe\u7247\r\ndone &lt; pics.url  #\u4ece\u6587\u4ef6\u4e2d\u8bfb\u53d6\u6bcf\u4e00\u884c\u8fdb\u884c\u5904\u7406\r\n<\/pre>\n<p>\u7b2c\u4e94\u6b65\uff1a<\/p>\n<p>\u5230\u73b0\u5728\u4e3a\u6b62\uff0c\u6211\u4eec\u8981\u505a\u7684\u6570\u636e\u51c6\u5907\u5de5\u4f5c\u5df2\u7ecf\u5b8c\u6210\u4e86\u3002\u6700\u540e\u5199\u4e86\u4e00\u4e2aphp\u811a\u672c\uff0c\u628a\u6587\u7ae0\u5185\u5bb9\u4e0e\u65f6\u95f4\u7b49\u4fe1\u606f\uff0c\u5b58\u5230wordpress\u76f8\u5e94\u7684\u6570\u636e\u8868\u4e2d\u3002post2wp.php\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n<pre class=\"brush: php; title: ; notranslate\" title=\"\">\r\n&lt;!--?php\r\ndate_default_timezone_set('Asia\/Chongqing');\r\n$index_file = 'index_blog-cat.html';\r\n$f_handle = fopen($index_file, 'r');\r\nwhile(!feof($f_handle)){\r\n    $line = fgets($f_handle);\r\n\r\n    if(empty($line))\r\n        break;\r\n\r\n    $line_arr = explode('|', $line);\r\n\r\n    $blog_file = trim($line_arr&#x5B;0]);\r\n    $date_time = trim($line_arr&#x5B;1]);\r\n    $title = htmlspecialchars(trim($line_arr&#x5B;2]));\r\n    $cat = trim($line_arr&#x5B;3]);\r\n\r\n    processBlog($blog_file, $title, $date_time, $cat);\r\n}\r\n\r\n$sql = 'update wp_term_taxonomy w1 set w1.count = (select count(*) from wp_term_relationships\r\n        where term_taxonomy_id = w1.term_taxonomy_id)';\r\n$res = mysql_query($sql);  \/\/\u66f4\u65b0\u6bcf\u4e2a\u76ee\u5f55\u4e0b\u9762\u6709\u591a\u5c11\u6587\u7ae0\r\n\r\nfunction processBlog($blog_file, $title, $date_time, $cat){\r\n    $cat_arr = array(\r\n        '\u9ed8\u8ba4\u5206\u7c7b' =&gt; 1,\r\n        '\u5de5\u5177\u6559\u7a0b' =&gt; 3,\r\n        '\u6280\u672f\u6587\u7ae0' =&gt; 4,\r\n        '\u4e2a\u4eba\u65e5\u8bb0' =&gt; 5,\r\n        '\u7f16\u7a0b\u76f8\u5173' =&gt; 6,\r\n        'delphi\u7f16\u7a0b' =&gt; 7,\r\n        '\u7cbe\u54c1\u6587\u7ae0' =&gt; 8,\r\n        '\u539f\u521b\u4f5c\u54c1' =&gt; 9,\r\n        '\u5b66\u4e60\u7b14\u8bb0' =&gt; 10,\r\n        '\u7f51\u9875\u7f16\u7a0b' =&gt; 11,\r\n        '.net\u7f16\u7a0b' =&gt; 12\r\n    );\r\n\r\n    $handle = fopen($blog_file, 'r');\r\n    $blog_content = fread($handle, filesize($blog_file));\r\n    $blog_content = mysql_real_escape_string($blog_content);\r\n\r\n    $post_time = strtotime($date_time);\r\n    $post_time_gmt = date('Y-m-d h:i:s', $post_time - 8*3600);\r\n    \/\/echo $post_time_gmt; exit();\r\n\r\n    $sql = &quot;INSERT INTO wp_posts (\r\n            post_author, post_date, post_date_gmt, post_content, post_title,\r\n            post_excerpt,post_status, comment_status, ping_status, post_password,\r\n            post_name, to_ping, pinged, post_modified, post_modified_gmt,\r\n            post_content_filtered, post_parent, guid, menu_order, post_type,\r\n            post_mime_type, comment_count) VALUES (&quot;\r\n            .&quot;1,'{$date_time}', '{$post_time_gmt}', '{$blog_content}', '{$title}',&quot;\r\n            . &quot;'', 'publish', 'open', 'open', '',&quot;\r\n            . &quot;'', '', '', '{$date_time}', '{$post_time_gmt}', &quot;\r\n            . &quot;'', 0, '', 0, 'post', &quot;\r\n            . &quot;'', 0);&quot;;\r\n    \/\/echo $sql; exit();\r\n    mysql_connect('localhost', 'root', 'hacklzt');\r\n    mysql_select_db('wp_blog');\r\n    mysql_query('SET NAMES UTF8;');\r\n    $res = mysql_query($sql);  \/\/\u63d2\u5165\u6587\u7ae0\r\n    if(empty($res)){\r\n        echo &quot;$title  \u5931\u8d25&quot;;\r\n    }\r\n    $ins_id = mysql_insert_id();\r\n    if(array_key_exists($cat, $cat_arr)){\r\n        $sql = &quot;INSERT INTO wp_term_relationships (object_id, term_taxonomy_id, term_order) &quot;.\r\n            &quot;VALUES ($ins_id, $cat_arr&#x5B;$cat], 0);&quot;;\r\n        $res = mysql_query($sql);   \/\/\u63d2\u5165\u6b64\u6587\u7ae0\u7684\u5206\u7c7b\r\n        if(empty($res)){\r\n            echo &quot;$title  \u5206\u7c7b\u5931\u8d25&quot;;\r\n        }else{\r\n\r\n        }\r\n    }else{\r\n        echo &quot;$title  \u5206\u7c7b\u5931\u8d25&quot;;\r\n    }\r\n}\r\n?&gt;\r\n<\/pre>\n<p>\u7528\u547d\u4ee4 php post2wp.php\uff0c\u5c31\u53ef\u4ee5\u76f4\u63a5\u8fd0\u884c\u8be5php\u6587\u4ef6\u3002<\/p>\n<p>OK\uff0c\u6536\u5de5\u3002<\/p>\n<p>\u6b64\u5916\uff0c\u73b0\u53d1\u73b0\u6587\u7ae0\u91cc\u9762\u7684\u94fe\u63a5\u4e0d\u5bf9\uff0c\u53ef\u4ee5\u7528SQL\u8bed\u53e5\u6765\u4fee\u6b63\uff1a<\/p>\n<pre class=\"brush: sql; light: true; title: ; notranslate\" title=\"\">\r\nUPDATE wp_posts SET post_content = REPLACE( post_content, '\u539f\u5185\u5bb9', ' \u65b0\u5185\u5bb9' ) ;\r\n<\/pre>\n<p>\u5176\u5b9e\u4e0a\u9762\u7684\u811a\u672c\u6211\u662f\u8c03\u8bd5\u4e86\u5f88\u4e45\u624d\u6700\u7ec8\u5b8c\u6210\u7684\uff0c\u6240\u4ee5\u7a0b\u5e8f\u4e0d\u662f\u5199\u51fa\u6765\u7684\uff0c\u662f\u8c03\u51fa\u6765\u7684\uff0c\u54c8\u54c8\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e0a\u5468\u672b\u82b1\u4e86\u4e24\u5929\u65f6\u95f4\uff0c\u7ec8\u4e8e\u628a\u535a\u5ba2\u8fc1\u79fb\u4e86\u8fc7\u6765\uff0c\u6240\u6709\u6587\u7ae0\u4e0e\u56fe\u7247\u90fd\u5b8c\u6574\u5730\u4fdd\u7559\u5728\u65b0\u535a\u5ba2\u4e2d\u3002 \u5176\u5b9e\u5f88\u65e9\u5c31\u6709\u628a\u535a\u5ba2\u8f6c\u6210\u72ec\u95e8\u535a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5],"tags":[],"class_list":["post-1919","post","type-post","status-publish","format-standard","hentry","category-diary"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/1919","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=1919"}],"version-history":[{"count":9,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/1919\/revisions"}],"predecessor-version":[{"id":4492,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/1919\/revisions\/4492"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=1919"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=1919"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=1919"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}