{"id":299,"date":"2025-08-14T01:29:11","date_gmt":"2025-08-14T01:29:11","guid":{"rendered":"http:\/\/noting.online\/?p=299"},"modified":"2026-05-09T01:27:03","modified_gmt":"2026-05-08T17:27:03","slug":"%e5%90%8c%e6%ad%a5csdn%e5%8d%9a%e5%ae%a2%e8%87%b3wordpress-2","status":"publish","type":"post","link":"https:\/\/noting.online\/?p=299","title":{"rendered":"\u540c\u6b65CSDN\u535a\u5ba2\u81f3wordpress"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">\u83b7\u53d6\u5f85\u540c\u6b65\u7684\u6587\u7ae0id\u5217\u8868<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728\u5185\u5bb9\u7ba1\u7406\u9875\u9762\u4f7f\u7528\u81ea\u52a8\u722c\u53d6\u7684\u65b9\u6cd5\u4e0d\u592a\u597d\u722c\u53d6\uff0c\u4ec5\u80fd\u83b7\u53d6\u67d0\u4e00\u9875\u7684\u6570\u636e\uff0820\u6761\u6587\u7ae0\uff09\uff0c\u5207\u6362\u5230\u5176\u4ed6\u9875\u65f6\u8bf7\u6c42\u5934\u53d1\u751f\u53d8\u5316\u5bfc\u81f4\u65e0\u6cd5\u83b7\u53d6\u5185\u5bb9\u3002\u56e0\u6b64\u8fd9\u91cc\u4ec5\u722c\u53d6\u9996\u9875\u516c\u5f00\u7684\u6587\u7ae0\u5217\u8868\uff08\u6240\u4ee5\u4e0d\u662f\u90a3\u4e48\u5168\uff09\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7528\u6237\u4e3b\u9875\u7684\u5730\u5740\u4e3a<a href=\"https:\/\/blog.csdn.net\/\" title=\"&nbsp;https:\/\/blog.csdn.net\/\">&nbsp;https:\/\/blog.csdn.net\/<\/a>&nbsp;+\u7528\u6237\u540d\uff0c\u6253\u5f00\u4e3b\u9875\u540e\u5ba1\u67e5\u5143\u7d20\uff0c\u8fdb\u5165\u7f51\u7edc\uff0c\u5e76\u5237\u65b0\u9875\u9762\uff0c\u5728\u67d0\u4e00\u6587\u4ef6\u5185\u53ef\u4ee5\u770b\u5230\u8fd4\u56de\u7684\u6570\u636e\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1268\" src=\"\/\/images.weserv.nl\/?url=https:\/\/i-blog.csdnimg.cn\/direct\/4d32fa332d81415eb26f154bfec386b0.png\" width=\"2560\">\u5c06\u8be5\u6587\u4ef6\u590d\u5236\u4e3acURL(bash)\uff0c\u5e76\u7c98\u8d34\u5230<a href=\"https:\/\/curlconverter.com\/\" rel=\"nofollow\" title=\"Convert curl commands to code\">Convert curl commands to code<\/a>&nbsp;\u4ee5\u81ea\u52a8\u751f\u6210\u4ee3\u7801\u3002<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"enlighter\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cookies = {\n    ...\n}\n\nheaders = {\n    ...\n}\n\nparams = {\n    'userName': '...', \u00a0 \u00a0 'page': '1',\n}\nr1 = requests.get('https:\/\/blog.csdn.net\/phoenix\/web\/article\/list', params=params, cookies=cookies, headers=headers)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u8981\u83b7\u53d6\u7684\u6587\u7ae0\u5217\u8868\u53ef\u80fd\u5728\u4e0d\u540c\u7684page\u4e0a\uff0c\u901a\u8fc7params\u53c2\u6570\u63a7\u5236page\u3002\u83b7\u53d6\u6587\u7ae0\u603b\u6570\uff0c\u8ba1\u7b97\u51fa\u6709\u591a\u5c11page\uff08\u6bcf\u4e2apage\u670940\u6761\u6587\u7ae0\uff09\uff0c\u7136\u540e\u904d\u5386\u5373\u53ef\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"enlighter\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">articleId_list=[d['articleId'] for d in r1.json()['data']['articleList']]\narticle_count=r1.json()['data']['total']\nfor p in range(2,math.ceil(article_count\/40)+1):\n    params = {\n    'userName': '\u7528\u6237\u540d',\n    'page': str(p),\n    }\n    r1 = requests.get('https:\/\/blog.csdn.net\/phoenix\/web\/article\/list', params=params, cookies=cookies, headers=headers)\n    page_articleId_list=[d['articleId'] for d in r1.json()['data']['articleList']]\n    if page_articleId_list:\n        articleId_list.extend(page_articleId_list)<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u83b7\u53d6\u6587\u7ae0\u5185\u5bb9<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6bcf\u4e00\u7bc7\u6587\u7ae0\u8be6\u60c5\u9875\u7684url\u683c\u5f0f\u4e3a&nbsp; https:\/\/blog.csdn.net\/\u7528\u6237\u540d\/article\/details\/\u6587\u7ae0id\uff0c\u8fd9\u91cc\u6211\u4eec\u83b7\u53d6\u6bcf\u4e00\u7bc7\u6587\u7ae0\u7684\u5185\u5bb9\uff0c\u7136\u540e\u7528BeautifulSoup\u5e93\u89e3\u6790\u51fa\u6807\u9898\u548c\u6b63\u6587\u5185\u5bb9\u5e76\u5199\u5165\u6570\u636e\u5e93\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u540c\u6837\u4f7f\u7528\u521a\u624d\u7684\u65b9\u6cd5\uff0c\u6253\u5f00\u67d0\u7bc7\u6587\u7ae0\uff0c\u5ba1\u67e5\u5143\u7d20\uff0c\u8fdb\u5165\u7f51\u7edc\uff0c\u5e76\u5237\u65b0\u9875\u9762\uff0c\u5728\u67d0\u4e00\u6587\u4ef6\u5185\u53ef\u4ee5\u770b\u5230\u8fd4\u56de\u7684\u6570\u636e\uff0c\u5c06\u8be5\u6587\u4ef6\u590d\u5236\u4e3acURL(bash)\uff0c\u5e76\u7c98\u8d34\u5230<a href=\"https:\/\/curlconverter.com\/\" rel=\"nofollow\" title=\"Convert curl commands to code\">Convert curl commands to code<\/a>&nbsp;\u4ee5\u81ea\u52a8\u751f\u6210\u4ee3\u7801\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">cookies = {\n    ...\n}\n\nheaders = {\n    ...\n}\n\nparams = {\n    ...\n}\ntitle_content_dict={}\nr2 = requests.get(\n        'https:\/\/blog.csdn.net\/\u7528\u6237\u540d\/article\/details\/'+str(a),\n        params=params,\n        cookies=cookies,\n        headers=headers,\n)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u67e5\u770b\u6587\u7ae0\u6807\u9898\u548c\u5185\u5bb9\u6240\u4f7f\u7528\u7684\u6807\u8bb0\uff0c\u53d1\u73b0\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6b63\u6587\u5185\u5bb9\u653e\u5728id\u4e3acontent_views\u7684div\u5757\u4e2d\uff0c\u76f4\u63a5\u7528find()\u65b9\u6cd5\u83b7\u53d6\u5373\u53ef\uff0c\u8fd4\u56de\u503c\u4ecd\u4e3aBeautifulSoup\u5bf9\u8c61\uff1b<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6587\u7ae0\u7684\u6807\u9898\u53ef\u4f7f\u7528find()\u65b9\u6cd5\u83b7\u53d6\uff0c\u4f20\u5165\u53c2\u6570\u4e3a\uff1a\u6807\u8bb0\u7b26\u540d\u79f0span\uff0c\u53ca\u503c\u4e3atit\u7684class\u5c5e\u6027\u7528\u4e8e\u7b5b\u9009\uff08\u8fd9\u91cc\u63cf\u8ff0\u548c\u4e0b\u56fe\u4e0d\u4e00\u81f4\uff0c\u53ef\u80fd\u4e5f\u53ef\u4ee5\u4f7f\u7528\u5176\u4ed6\u6807\u8bb0\u7b26\uff09\uff1b<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"1268\" src=\"\/\/images.weserv.nl\/?url=https:\/\/i-blog.csdnimg.cn\/direct\/939fb7f8e57142c995eb20d488810833.png\" width=\"2560\"><br> &nbsp;<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">soup=BeautifulSoup(r2.text)\narticle_title=soup.find('span',attrs={'class':'tit'}).string\ncontent_div_soup=soup.find('div',id='content_views')<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u5c06\u6587\u7ae0\u5199\u5165wordpress\u6570\u636e\u5e93<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">wordpress\u7684\u6587\u7ae0\u5185\u5bb9\u5b58\u653e\u5728 wordpress\u6570\u636e\u5e93&gt;wp_posts\u8868\u4e2d\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"sql\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">mysql> use wordpress;\nReading table information for completion of table and column names\nYou can turn off this feature to get a quicker startup with -A\n\nDatabase changed\nmysql> show tables;\n+-----------------------+\n| Tables_in_wordpress   |\n+-----------------------+\n| wp_commentmeta        |\n| wp_comments           |\n| wp_links              |\n| wp_options            |\n| wp_postmeta           |\n| wp_posts              |\n| wp_term_relationships |\n| wp_term_taxonomy      |\n| wp_termmeta           |\n| wp_terms              |\n| wp_usermeta           |\n| wp_users              |\n+-----------------------+\n12 rows in set (0.00 sec)\n\nmysql> desc wp_posts;\n+-----------------------+---------------------+------+-----+---------------------+----------------+\n| Field                 | Type                | Null | Key | Default             | Extra          |\n+-----------------------+---------------------+------+-----+---------------------+----------------+\n| ID                    | bigint(20) unsigned | NO   | PRI | NULL                | auto_increment |\n| post_author           | bigint(20) unsigned | NO   | MUL | 0                   |                |\n| post_date             | datetime            | NO   |     | 0000-00-00 00:00:00 |                |\n| post_date_gmt         | datetime            | NO   |     | 0000-00-00 00:00:00 |                |\n| post_content          | longtext            | NO   |     | NULL                |                |\n| post_title            | text                | NO   |     | NULL                |                |\n| post_excerpt          | text                | NO   |     | NULL                |                |\n| post_status           | varchar(20)         | NO   |     | publish             |                |\n| comment_status        | varchar(20)         | NO   |     | open                |                |\n| ping_status           | varchar(20)         | NO   |     | open                |                |\n| post_password         | varchar(255)        | NO   |     |                     |                |\n| post_name             | varchar(200)        | NO   | MUL |                     |                |\n| to_ping               | text                | NO   |     | NULL                |                |\n| pinged                | text                | NO   |     | NULL                |                |\n| post_modified         | datetime            | NO   |     | 0000-00-00 00:00:00 |                |\n| post_modified_gmt     | datetime            | NO   |     | 0000-00-00 00:00:00 |                |\n| post_content_filtered | longtext            | NO   |     | NULL                |                |\n| post_parent           | bigint(20) unsigned | NO   | MUL | 0                   |                |\n| guid                  | varchar(255)        | NO   |     |                     |                |\n| menu_order            | int(11)             | NO   |     | 0                   |                |\n| post_type             | varchar(20)         | NO   | MUL | post                |                |\n| post_mime_type        | varchar(100)        | NO   |     |                     |                |\n| comment_count         | bigint(20)          | NO   |     | 0                   |                |\n+-----------------------+---------------------+------+-----+---------------------+----------------+\n23 rows in set (0.04 sec)<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5411\u8868\u4e2d\u5199\u5165\u6587\u7ae0\u6570\u636e\u65f6\uff0c\u586b\u5165\u5fc5\u586b\u5b57\u6bb5\u5373\u53ef\uff0c\u5305\u62ec<\/p>\n\n\n<ul>\n<li>post_date<\/li>\n<li>post_date_gmt<\/li>\n<li>post_modified<\/li>\n<li>post_modified_gmt<\/li>\n<li>post_title\uff1a\u6587\u7ae0\u6807\u9898<\/li>\n<li>post_excerpt<\/li>\n<li>to_ping<\/li>\n<li>pinged<\/li>\n<li>post_content_filtered<\/li>\n<li>post_content\uff1a\u6587\u7ae0\u6b63\u6587\u5185\u5bb9<\/li>\n<\/ul>\n\n\n<p class=\"wp-block-paragraph\">&nbsp;\u4ee5\u4e0a\u5b57\u6bb5\u5199\u5165\u65f6\u5747\u53ef\u4f20\u5165\u5b57\u7b26\u4e32\u53c2\u6570\u3002\u524d\u56db\u4e2a\u4e3a\u65f6\u95f4\uff0c\u53ef\u8bbe\u7f6e\u4e3a\u5f53\u524d\u65f6\u95f4\uff1b\u6700\u91cd\u8981\u7684\u5b57\u6bb5\u4e3apost_title\u548cpost_content\uff0c\u5206\u522b\u4e3a\u6587\u7ae0\u6807\u9898\u548c\u5185\u5bb9\uff1b\u5176\u4ed6\u5b57\u6bb5\u7f6e\u4e3a\u7a7a\u5b57\u7b26\u4e32\u5373\u53ef\uff1b<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u8fd9\u91cc\u4f7f\u7528pymysql\u5199\u5165\u6570\u636e\u5e93\uff0c\u4f7f\u7528escape_string\u5904\u7406\u5355\u5f15\u53f7\u3001\u53cc\u5f15\u53f7\u7b49\u7279\u6b8a\u5b57\u7b26\u3002\u5982\u679c\u5c06\u6e90\u4ee3\u7801\u76f4\u63a5\u5199\u5165\u6570\u636e\u5e93\uff0c\u56fe\u7247\u662f\u65e0\u6cd5\u663e\u793a\u7684\uff0c\u8fd9\u91cc\u5c06\u56fe\u7247\u94fe\u63a5\u524d\u52a0\u4e0a\/\/images.weserv.nl\/?url=\u8fdb\u884c\u5904\u7406\u540e\u65b9\u53ef\u663e\u793a\uff1a<\/p>\n\n\n\n\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">con = pymysql.connect(host='12.34.56.78',user='root',port=3306,database='wordpress',password='123456')\ncur= con.cursor()\n\ncontent_str=str(content_div_soup).replace('\/\/images.weserv.nl\/?url=https:\/\/i-blog.csdnimg.cn','\/\/images.weserv.nl\/?url=\/\/images.weserv.nl\/?url=https:\/\/i-blog.csdnimg.cn')\ntime=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')\nsql='''insert into wp_posts(\n        post_date,post_date_gmt,post_modified,post_modified_gmt,post_title,\n        post_excerpt,to_ping,pinged,post_content_filtered,post_content) \n        values( \n        '%s','%s','%s','%s','%s',\n        '%s','%s','%s','%s','%s')''' \n        %(time,time,time,time,article_title,\n          '','','','',escape_string(content_str))\ncur.execute(sql)\ncon.commit()<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u5199\u5165\u540e\uff0c\u5237\u65b0\u535a\u5ba2\u4e3b\u9875\uff0c\u5c31\u80fd\u770b\u5230\u65b0\u751f\u6210\u7684\u6587\u7ae0\u4e86\u3002<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">\u5168\u90e8\u4ee3\u7801<\/h2>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">from bs4 import BeautifulSoup\nimport re,requests,math,pymysql\nfrom tqdm import tqdm\n# v1.0.0\u53ca\u4ee5\u4e0a\nfrom pymysql.converters import escape_string\n# v0.10.1\u53ca\u4ee5\u4e0b\n#from pymysql import escape_string\n\n# \u4ece\u4e3b\u9875\u83b7\u53d6\u6240\u6709\u6587\u7ae0\u7f16\u53f7\uff0c\u8fd9\u91cc\u53ea\u80fd\u83b7\u53d6\u516c\u5f00\u7684\u3002#\u5982\u679c\u4ece\u5185\u5bb9\u7ba1\u7406\u9875\u9762\u83b7\u53d6\uff0c\u4ec5\u80fd\u83b7\u53d6\u67d0\u9875\u768420\u4e2a\uff0c\u5207\u6362\u5230\u5176\u4ed6\u9875\u65f6\uff0c\u8bf7\u6c42\u5934\u4f1a\u53d8\uff0c\u5bfc\u81f4\u65e0\u6cd5\u83b7\u53d6\u5230\u6570\u636e\ncookies = {\n    ...,\n}\n\nheaders = {\n    ...,\n}\n\nparams = {\n    ...,\n}\n\nr1 = requests.get('https:\/\/blog.csdn.net\/phoenix\/web\/article\/list', params=params, cookies=cookies, headers=headers)\narticleId_list=[d['articleId'] for d in r1.json()['data']['articleList']]\narticle_count=r1.json()['data']['total']\nfor p in range(2,math.ceil(article_count\/40)+1):\n    params = {\n    'userName': '...',\n    'page': str(p),\n    }\n    r1 = requests.get('https:\/\/blog.csdn.net\/phoenix\/web\/article\/list', params=params, cookies=cookies, headers=headers)\n    page_articleId_list=[d['articleId'] for d in r1.json()['data']['articleList']]\n    if page_articleId_list:\n        articleId_list.extend(page_articleId_list)\nprint(len(articleId_list))\n\n\n# \u5c06\u6587\u7ae0\u5199\u5165wordpress\u6570\u636e\u5e93\ncon = pymysql.connect(host='12.34.56.78',user='Admin',port=3306,database='wordpress',password='123456')\ncur= con.cursor()\n\ncookies = {\n    ...,\n}\n\nheaders = {\n    ...,\n}\n\nparams = {\n    ...,\n}\nfor a in tqdm(articleId_list[:]):\n    r2 = requests.get(\n        'https:\/\/blog.csdn.net\/\u7528\u6237\u540d\/article\/details\/'+str(a),\n        params=params,\n        cookies=cookies,\n        headers=headers,\n    )\n    soup=BeautifulSoup(r2.text)\n    article_title=soup.find('span',attrs={'class':'tit'}).string\n    content_div_soup=soup.find('div',id='content_views')\n    content_str=str(content_div_soup).replace('\/\/images.weserv.nl\/?url=https:\/\/i-blog.csdnimg.cn','\/\/images.weserv.nl\/?url=\/\/images.weserv.nl\/?url=https:\/\/i-blog.csdnimg.cn')\n    time=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')\n    sql='''insert into wp_posts(\n        post_date,post_date_gmt,post_modified,post_modified_gmt,post_title,\n        post_excerpt,to_ping,pinged,post_content_filtered,post_content) \n        values( \n        '%s','%s','%s','%s','%s',\n        '%s','%s','%s','%s','%s')''' \n        %(time,time,time,time,article_title,\n          '','','','',escape_string(content_str))\n    cur.execute(sql)\n    con.commit()\nprint('Finished.')<\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">\u6539\u8fdb<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u6309\u7167\u4ee5\u4e0a\u64cd\u4f5c\uff0c\u6587\u7ae0\u5185\u5bb9\u5012\u662f\u53ef\u4ee5\u540c\u6b65\u8fc7\u53bb\uff0c\u4f46\u662f\u5728wordpress\u4e2d\u8fdb\u884c\u7f16\u8f91\u65f6\u6240\u6709\u5185\u5bb9\u90fd\u653e\u5728\u4e86\u4e00\u4e2a\u5757\u5185\uff0c\u4ec5\u80fd\u7528\u7ecf\u5178\u7f16\u8f91\u5668\u53bb\u7f16\u8f91\uff0c\u4e0e\u5728wordpress\u4e2d\u624b\u5199\u6587\u7ae0\u65f6\u5dee\u5f02\u8f83\u5927\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5206\u6790\u4e00\u4e2a\u624b\u5199wordpress\u6587\u7ae0\u7684\u6e90\u4ee3\u7801\u53ef\u4ee5\u53d1\u73b0\uff0c\u6e90\u4ee3\u7801\u9664\u4e86\u5e38\u89c4\u7684\u6807\u8bb0\u7b26\u5916\uff0c\u8fd8\u7528\u6ce8\u91ca\u6807\u8bb0\u7b26\u5c06\u5e38\u89c4\u6807\u8bb0\u7b26\u524d\u540e\u5305\u56f4\u4e86\u8d77\u6765\uff0c\u5e76\u4ee5\u7a7a\u884c\u9694\u5f00\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6bb5\u843d\uff1a\u6807\u8bb0\u5185\u5bb9\u653e\u5728&lt;!&#8211; wp:paragraph &#8211;&gt;\u548c&lt;!&#8211; \/wp:paragraph &#8211;&gt;\u4e4b\u95f4\uff1b<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6807\u9898\uff1a\u6807\u8bb0\u5185\u5bb9\u653e\u5728&lt;!&#8211; wp:heading {&#8220;level&#8221;:1} &#8211;&gt;\u548c&lt;!&#8211; \/wp:heading &#8211;&gt;\u4e4b\u95f4\uff1b<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u56fe\u7247\uff1a\u6807\u8bb0\u5185\u5bb9\u653e\u5728&lt;!&#8211; wp:image {&#8220;id&#8221;:18,&#8221;sizeSlug&#8221;:&#8221;large&#8221;,&#8221;linkDestination&#8221;:&#8221;none&#8221;} &#8211;&gt; \u548c&lt;\/figure&gt; &lt;!&#8211; \/wp:image &#8211;&gt;\u4e4b\u95f4\uff1b\u5982\u679c\u540c\u4e00\u884c\u6709\u591a\u5f20\u56fe\u7247\uff0c\u5916\u9762\u518d\u7528<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">&lt;!&#8211; wp:gallery {&#8220;linkTo&#8221;:&#8221;none&#8221;} &#8211;&gt;\u548c&lt;!&#8211; \/wp:gallery &#8211;&gt;\u5305\u542b\uff1b<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5217\u8868\u5411\uff1a&lt;!&#8211; wp:list-item &#8211;&gt;\u548c&lt;!&#8211; \/wp:list-item &#8211;&gt;\uff1b<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">&lt;!-- wp:heading {\"level\":1} -->\n&lt;h1 class=\"wp-block-heading\">\u4e00\u7ea7\u6807\u98981&lt;\/h1>\n&lt;!-- \/wp:heading -->\n\n&lt;!-- wp:paragraph -->\n&lt;p>\u8fd9\u662f\u4e00\u7ea7\u6807\u9898\u7684\u5185\u5bb9\u3002&lt;\/p>\n&lt;!-- \/wp:paragraph -->\n\n&lt;!-- wp:heading -->\n&lt;h2 class=\"wp-block-heading\">\u4e8c\u7ea7\u6807\u9898&lt;\/h2>\n&lt;!-- \/wp:heading -->\n\n&lt;!-- wp:paragraph -->\n&lt;p>\u56fe\u7247\u548c\u52a8\u56fe&lt;\/p>\n&lt;!-- \/wp:paragraph -->\n\n&lt;!-- wp:gallery {\"linkTo\":\"none\"} -->\n&lt;figure class=\"wp-block-gallery has-nested-images columns-default is-cropped\">&lt;!-- wp:image {\"id\":18,\"sizeSlug\":\"large\",\"linkDestination\":\"none\"} -->\n&lt;figure class=\"wp-block-image size-large\">&lt;img src=\"http:\/\/noting.online\/wp-content\/uploads\/2025\/07\/Snipaste_2025-07-31_02-03-07.png\" alt=\"\" class=\"wp-image-18\"\/>&lt;\/figure>\n&lt;!-- \/wp:image -->\n\n&lt;!-- wp:image {\"id\":20,\"width\":\"206px\",\"height\":\"auto\",\"sizeSlug\":\"large\",\"linkDestination\":\"none\"} -->\n&lt;figure class=\"wp-block-image size-large is-resized\">&lt;img src=\"http:\/\/noting.online\/wp-content\/uploads\/2025\/07\/\u89c6\u9891\u6837\u672c.gif\" alt=\"\" class=\"wp-image-20\" style=\"width:206px;height:auto\"\/>&lt;\/figure>\n&lt;!-- \/wp:image -->&lt;\/figure>\n&lt;!-- \/wp:gallery -->\n\n&lt;!-- wp:heading {\"level\":3} -->\n&lt;h3 class=\"wp-block-heading\">\u4e09\u7ea7\u6807\u9898&lt;\/h3>\n&lt;!-- \/wp:heading -->\n\n&lt;!-- wp:paragraph -->\n&lt;p>\u4e00\u4e2a\u8d85\u94fe\u63a5&lt;\/p>\n&lt;!-- \/wp:paragraph -->\n\n&lt;!-- wp:paragraph -->\n&lt;p>&lt;a href=\"https:\/\/www.runoob.com\/linux\/linux-file-attr-permission.html\">https:\/\/www.runoob.com\/linux\/linux-file-attr-permission.html&lt;\/a>&lt;\/p>\n&lt;!-- \/wp:paragraph -->\n\n&lt;!-- wp:heading {\"level\":4} -->\n&lt;h4 class=\"wp-block-heading\">\u56db\u7ea7\u6807\u9898&lt;\/h4>\n&lt;!-- \/wp:heading -->\n\n&lt;!-- wp:paragraph -->\n&lt;p>\u4e00\u6bb5\u4ee3\u7801&lt;\/p>\n&lt;!-- \/wp:paragraph -->\n\n&lt;!-- wp:wb\/wp-vk {\"vkMark\":\"\"} -->\n\n&lt;!-- \/wp:wb\/wp-vk -->\n\n&lt;!-- wp:group {\"layout\":{\"type\":\"constrained\"}} -->\n&lt;div class=\"wp-block-group\">&lt;!-- wp:columns -->\n&lt;div class=\"wp-block-columns\">&lt;!-- wp:column {\"width\":\"100%\"} -->\n&lt;div class=\"wp-block-column\" style=\"flex-basis:100%\">&lt;!-- wp:group {\"layout\":{\"type\":\"constrained\"}} -->\n&lt;div class=\"wp-block-group\">&lt;!-- wp:columns -->\n&lt;div class=\"wp-block-columns\">&lt;!-- wp:column {\"width\":\"100%\"} -->\n&lt;div class=\"wp-block-column\" style=\"flex-basis:100%\">&lt;!-- wp:group {\"layout\":{\"type\":\"constrained\"}} -->\n&lt;div class=\"wp-block-group\">&lt;!-- wp:columns -->\n&lt;div class=\"wp-block-columns\">&lt;!-- wp:column {\"width\":\"100%\"} -->\n&lt;div class=\"wp-block-column\" style=\"flex-basis:100%\">&lt;!-- wp:code -->\n&lt;pre class=\"wp-block-code\">&lt;code>print('Hello World')&lt;\/code>&lt;\/pre>\n&lt;!-- \/wp:code -->&lt;\/div>\n&lt;!-- \/wp:column -->&lt;\/div>\n&lt;!-- \/wp:columns -->&lt;\/div>\n&lt;!-- \/wp:group -->&lt;\/div>\n&lt;!-- \/wp:column -->&lt;\/div>\n&lt;!-- \/wp:columns -->&lt;\/div>\n&lt;!-- \/wp:group -->&lt;\/div>\n&lt;!-- \/wp:column -->&lt;\/div>\n&lt;!-- \/wp:columns -->&lt;\/div>\n&lt;!-- \/wp:group -->\n\n&lt;!-- wp:heading {\"level\":5} -->\n&lt;h5 class=\"wp-block-heading\">\u4e94\u7ea7\u6807\u9898&lt;\/h5>\n&lt;!-- \/wp:heading -->\n\n&lt;!-- wp:html -->\n[]\n&lt;!-- \/wp:html -->\n\n&lt;!-- wp:paragraph -->\n&lt;p>\u4e00\u4e2a\u8868\u683c&lt;\/p>\n&lt;!-- \/wp:paragraph -->\n\n&lt;!-- wp:columns -->\n&lt;div class=\"wp-block-columns\">&lt;!-- wp:column {\"width\":\"100%\"} -->\n&lt;div class=\"wp-block-column\" style=\"flex-basis:100%\">&lt;!-- wp:group {\"layout\":{\"type\":\"grid\"}} -->\n&lt;div class=\"wp-block-group\">&lt;!-- wp:group {\"layout\":{\"type\":\"constrained\"}} -->\n&lt;div class=\"wp-block-group\">&lt;!-- wp:columns -->\n&lt;div class=\"wp-block-columns\">&lt;!-- wp:column {\"width\":\"100%\"} -->\n&lt;div class=\"wp-block-column\" style=\"flex-basis:100%\">&lt;!-- wp:group {\"layout\":{\"type\":\"grid\"}} -->\n&lt;div class=\"wp-block-group\">&lt;!-- wp:group {\"layout\":{\"type\":\"constrained\"}} -->\n&lt;div class=\"wp-block-group\">&lt;!-- wp:table -->\n&lt;figure class=\"wp-block-table\">&lt;table class=\"has-fixed-layout\">&lt;tbody>&lt;tr>&lt;td>&lt;\/td>&lt;td>\u52171&lt;\/td>&lt;td>\u52172&lt;\/td>&lt;\/tr>&lt;tr>&lt;td>\u884c1&lt;\/td>&lt;td>&lt;\/td>&lt;td>&lt;\/td>&lt;\/tr>&lt;tr>&lt;td>\u884c2&lt;\/td>&lt;td>&lt;\/td>&lt;td>&lt;\/td>&lt;\/tr>&lt;\/tbody>&lt;\/table>&lt;\/figure>\n&lt;!-- \/wp:table -->&lt;\/div>\n&lt;!-- \/wp:group -->&lt;\/div>\n&lt;!-- \/wp:group -->&lt;\/div>\n&lt;!-- \/wp:column -->&lt;\/div>\n&lt;!-- \/wp:columns -->&lt;\/div>\n&lt;!-- \/wp:group -->&lt;\/div>\n&lt;!-- \/wp:group -->&lt;\/div>\n&lt;!-- \/wp:column -->&lt;\/div>\n&lt;!-- \/wp:columns -->\n\n&lt;!-- wp:heading {\"level\":6} -->\n&lt;h6 class=\"wp-block-heading\">\u516d\u7ea7\u6807\u9898&lt;\/h6>\n&lt;!-- \/wp:heading -->\n\n&lt;!-- wp:paragraph -->\n&lt;p>\u65e0\u5e8f\u5217\u8868&lt;\/p>\n&lt;!-- \/wp:paragraph -->\n\n&lt;!-- wp:list -->\n&lt;ul class=\"wp-block-list\">&lt;!-- wp:list-item -->\n&lt;li>\u65e0\u5e8f\u5217\u8868\u98791&lt;\/li>\n&lt;!-- \/wp:list-item -->\n\n&lt;!-- wp:list-item -->\n&lt;li>\u65e0\u5e8f\u5217\u8868\u98792&lt;\/li>\n&lt;!-- \/wp:list-item -->\n\n&lt;!-- wp:list-item -->\n&lt;li>\u65e0\u5e8f\u5217\u8868\u98793&lt;\/li>\n&lt;!-- \/wp:list-item -->&lt;\/ul>\n&lt;!-- \/wp:list -->\n\n&lt;!-- wp:paragraph -->\n&lt;p>\u6709\u5e8f\u5217\u8868&lt;\/p>\n&lt;!-- \/wp:paragraph -->\n\n&lt;!-- wp:list {\"ordered\":true} -->\n&lt;ol class=\"wp-block-list\">&lt;!-- wp:list-item -->\n&lt;li>\u6709\u5e8f\u5217\u8868\u98791&lt;\/li>\n&lt;!-- \/wp:list-item -->\n\n&lt;!-- wp:list-item -->\n&lt;li>\u6709\u5e8f\u5217\u8868\u98792&lt;\/li>\n&lt;!-- \/wp:list-item -->\n\n&lt;!-- wp:list-item -->\n&lt;li>\u6709\u5e8f\u5217\u8868\u98793&lt;\/li>\n&lt;!-- \/wp:list-item -->&lt;\/ol>\n&lt;!-- \/wp:list -->\n\n&lt;!-- wp:heading {\"level\":1} -->\n&lt;h1 class=\"wp-block-heading\">\u4e00\u7ea7\u6807\u98982&lt;\/h1>\n&lt;!-- \/wp:heading -->\n\n&lt;!-- wp:paragraph -->\n&lt;p>\u4e00\u7ea7\u6807\u98982\u7684\u6b63\u6587&lt;\/p>\n&lt;!-- \/wp:paragraph -->\n\n&lt;!-- wp:wb\/wp-vk {\"vkMark\":\"\"} -->\n\n&lt;!-- \/wp:wb\/wp-vk -->\n\n&lt;!-- wp:paragraph -->\n&lt;p>&lt;\/p>\n&lt;!-- \/wp:paragraph -->\n\n&lt;!-- wp:categories \/-->\n\n&lt;!-- wp:paragraph -->\n&lt;p>&lt;\/p>\n&lt;!-- \/wp:paragraph --><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u6240\u4ee5\u4f7f\u7528python\u5411\u6570\u636e\u5e93\u4e2d\u63d2\u5165\u4ee3\u7801\u65f6\uff0c\u8981\u60f3\u8fbe\u5230\u4e0e\u624b\u5199\u76f8\u540c\u7684\u6548\u679c\uff0c\u9700\u8981\u5c06\u83b7\u53d6\u7684html\u4ee3\u7801\u6309\u7167wordpress\u7684\u683c\u5f0f\u8fdb\u884c\u5904\u7406\u3002<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u6b64\u5904\u4ec5\u4ee5\u6bb5\u843d\u548c\u6807\u9898\u4e3a\u4f8b\uff0c\u5728\u6807\u8bb0\u7b26\u524d\u540e\u52a0\u4e0awordpress\u4e2d\u7684\u6807\u8bb0\u7b26\uff0c\u4f7f\u7528\u6b63\u5219\u8868\u8fbe\u5f0f\u66ff\u6362\u5b9e\u73b0\uff0c\u5176\u4ed6\u5730\u65b9\u7a0d\u4f5c\u4fee\u6539\uff0c\uff1a<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"python\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">for a in tqdm(articleId_list[:]):\n    r2 = requests.get(\n        'https:\/\/blog.csdn.net\/\u7528\u6237\u540d\/article\/details\/'+str(a),\n        params=params,\n        cookies=cookies,\n        headers=headers,\n    )\n    soup=BeautifulSoup(r2.text)\n    article_title=soup.find('span',attrs={'class':'tit'}).string\n    content_div_soup=soup.find('div',id='content_views')\n    s=''.join(list(map(str,content_div_soup.contents[1].contents)))\n    s=s.replace('\/\/images.weserv.nl\/?url=https:\/\/i-blog.csdnimg.cn','\/\/images.weserv.nl\/?url=\/\/images.weserv.nl\/?url=https:\/\/i-blog.csdnimg.cn')\n    s=re.sub(\"(&lt;h[1-6]>)\",r\"&lt;!-- wp:heading -->1\",s)\n    s=re.sub(\"(&lt;\/h[1-6]>)\",r\"1&lt;!-- \/wp:heading -->\",s)\n    s=re.sub(\"(&lt;p>)\",r\"&lt;!-- wp:paragraph -->1\",s)\n    s=re.sub(\"(&lt;\/p>)\",r\"1&lt;!-- \/wp:paragraph -->\",s)\n    time=datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')\n    sql='''insert into wp_posts(\n        post_date,post_date_gmt,post_modified,post_modified_gmt,post_title,\n        post_excerpt,to_ping,pinged,post_content_filtered,post_content) \n        values( \n        '%s','%s','%s','%s','%s',\n        '%s','%s','%s','%s','%s')''' \n        %(time,time,time,time,article_title,\n          '','','','',escape_string(s))\n    cur.execute(sql)\n    con.commit()\nprint('Finished.')<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u83b7\u53d6\u5f85\u540c\u6b65\u7684\u6587\u7ae0id\u5217\u8868 \u5728\u5185\u5bb9\u7ba1\u7406\u9875\u9762\u4f7f\u7528\u81ea\u52a8\u722c\u53d6\u7684\u65b9\u6cd5\u4e0d\u592a\u597d\u722c\u53d6\uff0c\u4ec5\u80fd\u83b7\u53d6\u67d0\u4e00\u9875\u7684\u6570\u636e\uff0820\u6761\u6587\u7ae0\uff09\uff0c\u5207\u6362\u5230\u5176\u4ed6\u9875\u65f6\u8bf7\u6c42\u5934\u53d1\u751f\u53d8\u5316\u5bfc\u81f4\u65e0\u6cd5\u83b7\u53d6\u5185\u5bb9\u3002\u56e0\u6b64\u8fd9\u91cc\u4ec5\u722c\u53d6\u9996\u9875\u516c\u5f00\u7684\u6587\u7ae0\u5217\u8868\uff08\u6240\u4ee5\u4e0d\u662f\u90a3\u4e48\u5168\uff09\u3002 \u7528\u6237\u4e3b\u9875\u7684\u5730\u5740\u4e3a&nbsp;https:\/\/blog.csdn.net\/&nbsp;+\u7528\u6237\u540d\uff0c [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":"","vk_price":"0"},"categories":[1],"tags":[],"class_list":["post-299","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"views":310,"_links":{"self":[{"href":"https:\/\/noting.online\/index.php?rest_route=\/wp\/v2\/posts\/299","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/noting.online\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/noting.online\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/noting.online\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/noting.online\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=299"}],"version-history":[{"count":6,"href":"https:\/\/noting.online\/index.php?rest_route=\/wp\/v2\/posts\/299\/revisions"}],"predecessor-version":[{"id":455,"href":"https:\/\/noting.online\/index.php?rest_route=\/wp\/v2\/posts\/299\/revisions\/455"}],"wp:attachment":[{"href":"https:\/\/noting.online\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=299"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/noting.online\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=299"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/noting.online\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=299"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}