﻿{"id":245,"date":"2026-02-03T16:40:05","date_gmt":"2026-02-03T08:40:05","guid":{"rendered":"http:\/\/blog.huihuia24.top\/index.php\/2026\/02\/03\/python%e7%88%ac%e8%99%ab\/"},"modified":"2026-02-03T16:45:43","modified_gmt":"2026-02-03T08:45:43","slug":"python%e7%88%ac%e8%99%ab","status":"publish","type":"post","link":"http:\/\/blog.huihuia24.top\/index.php\/2026\/02\/03\/python%e7%88%ac%e8%99%ab\/","title":{"rendered":"python\u722c\u866b"},"content":{"rendered":"<p>PDF\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"http:\/\/blog.huihuia24.top\/wp-content\/uploads\/2026\/02\/%E7%88%AC%E8%99%AB.pdf\">\u722c\u866bPDF<\/a><\/p>\n<h2>\u4e00\u3001\u722c\u866b\u7b80\u4ecb<\/h2>\n<h3>1.\u6a21\u5757\u51c6\u5907<\/h3>\n<p>requests<\/p>\n<p>lxml<\/p>\n<p>selenium<\/p>\n<p>scrapy<\/p>\n<p><strong>\u547d\u4ee4\uff1a<\/strong><\/p>\n<pre><code class=\"language-python\">pip install \u6a21\u5757\u540d\n<\/code><\/pre>\n<h3>2.\u722c\u866b\u7684\u5206\u7c7b<\/h3>\n<ol>\n<li>\n<p>\u5168\u7f51\u722c\u866b<\/p>\n<p>\u767e\u5ea6\u3001\u641c\u72d7\u3001Google\u3001bing<\/p>\n<\/li>\n<li>\n<p>\u805a\u7126\u722c\u866b<\/p>\n<p>\u9488\u5bf9\u5355\u4e00\u7f51\u7ad9\u7684\u641c\u7d22\u5de5\u5177<\/p>\n<\/li>\n<\/ol>\n<h3>3.\u722c\u866b\u7684\u6ce8\u610f\u70b9<\/h3>\n<ol>\n<li>\n<p>\u53d8\u5316\u975e\u5e38\u8fc5\u901f<\/p>\n<p>\u4eca\u5929\u4ee3\u7801\u6ca1\u95ee\u9898&#8212;&gt;\u660e\u5929\u4ee3\u7801\u4e0d\u884c\u4e86<\/p>\n<ul>\n<li>\u65f6\u95f4\u95ee\u9898<\/li>\n<li>\u8eab\u4efd\u95ee\u9898<\/li>\n<li>\u7f51\u7ad9\u53d8\u5316\n<ul>\n<li>\u7f51\u7ad9\u66f4\u65b0\u3001\u5347\u7ea7<\/li>\n<\/ul>\n<\/li>\n<li>\u7f51\u7ad9\u5d29\u6e83\u3001\u5012\u95ed<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u722c\u866b\u722c\u53d6\u6570\u636e\u7684\u6765\u6e90<\/p>\n<p><strong>\u7f51\u5740<\/strong><\/p>\n<ul>\n<li>\u7f51\u5740\u7684\u6784\u6210(\u6570\u636e\u6765\u6e90)\n<ul>\n<li>\u534f\u8bae<\/li>\n<li>\u57df\u540d<\/li>\n<li>\u8d44\u6e90\u76ee\u5f55<\/li>\n<li>\u641c\u7d22\u5173\u952e\u5b57<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u722c\u866b\u7684\u6d41\u7a0b<\/p>\n<ul>\n<li>\u5206\u6790\u7f51\u5740<\/li>\n<li>\u6784\u5efa\u722c\u866b<\/li>\n<li>\u6570\u636e\u6e05\u6d17<\/li>\n<li>\u6570\u636e\u4fdd\u5b58<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u722c\u866b\u4ee3\u7801\u95ee\u9898<\/p>\n<p>\u4e00\u4e2a\u4ee3\u7801\u53ea\u9002\u7528\u4e8e\u4e00\u4e2a\u7f51\u7ad9<\/p>\n<\/li>\n<li>\n<p>\u722c\u866b\u53ea\u80fd\u722c\u53d6\u53ef\u4ee5\u83b7\u53d6\u7684\u6570\u636e<\/p>\n<\/li>\n<li>\n<p>\u5b66\u4e60\u722c\u866b\u7684\u8fc7\u7a0b\u4e2d\uff0c\u4e0d\u8981\u8fc7\u591a\u7684\u53d1\u8d77\u8bf7\u6c42<\/p>\n<\/li>\n<\/ol>\n<h3>4.\u722c\u866b\u7684\u4f5c\u7528<\/h3>\n<p><strong>\u83b7\u53d6\u6570\u636e<\/strong><\/p>\n<ul>\n<li>\u6587\u5b57<\/li>\n<li>\u56fe\u7247<\/li>\n<li>\u89c6\u9891<\/li>\n<li>\u97f3\u9891<\/li>\n<\/ul>\n<p><strong>\u4e3a\u4e86\u6279\u91cf\u7684\u83b7\u53d6\u6570\u636e\u3001\u53ef\u4ee5\u8fdb\u884c\u81ea\u52a8\u5316\u7684\u64cd\u4f5c\u3001\u5feb\u901f\u7684\u83b7\u53d6<\/strong><\/p>\n<h3>5.\u53cd\u722c\u866b<\/h3>\n<p>\u5b66\u4e60\u5982\u4f55\u8bc6\u522b\u5bf9\u5e94\u7f51\u7ad9\u7684\u53cd\u722c\u7b56\u7565\uff0c\u4ece\u800c\u627e\u5230\u53ef\u4ee5\u901a\u8fc7\u53cd\u722c\u7b56\u7565\u7684\u65b9\u6cd5<\/p>\n<h2>\u4e8c\u3001\u6293\u5305\u5206\u6790<\/h2>\n<h3>1.\u6570\u636e\u6765\u6e90<\/h3>\n<p>\u6570\u636e\u5305\u7684\u5f62\u5f0f\u8fdb\u884c\u6570\u636e\u7684\u4f20\u8f93<\/p>\n<p>\u5ba2\u6237\u7aef &#8212;- \u53d1\u8d77\u8bf7\u6c42[\u8bf7\u6c42\u6570\u636e\u5305] &#8212;&gt; \u670d\u52a1\u7aef<br \/>\u5ba2\u6237\u7aef &lt;&#8212; \u8fd4\u56de\u6570\u636e[\u54cd\u5e94\u6570\u636e\u5305] &#8212;- \u670d\u52a1\u7aef<\/p>\n<h3>2.\u4ec0\u4e48\u662f\u6293\u5305\uff1f<\/h3>\n<p>\u5728\u5ba2\u6237\u7aef\u4e0e\u670d\u52a1\u5668\u4ea4\u4e92\u7684\u65f6\u5019\uff0c\u5bf9\u5176\u76f8\u4e92\u4f20\u8f93\u7684\u6570\u636e\u5305\u8fdb\u884c\u89e3\u6790\u4ece\u800c\u83b7\u53d6\u9700\u8981\u7684\u5185\u5bb9<\/p>\n<blockquote>\n<p>\u8865\u5145\uff1a\u6bcf\u4e2a\u7f51\u7ad9\u90fd\u662f\u72ec\u7acb\u7684\u5b58\u5728\uff0c\u56e0\u4e3a\u5f00\u53d1\u4eba\u5458\u7684\u4e0d\u540c\uff0c\u4e0d\u540c\u7684\u7f51\u7ad9\u6240\u5b9e\u884c\u7684\u65b9\u6cd5\u662f\u4e0d\u4e00\u6837\u7684<\/p>\n<\/blockquote>\n<h3>3.\u5982\u4f55\u6293\u5305(\u5f00\u53d1\u8005\u9009\u9879\u3001\u8c03\u8bd5\u63a7\u5236\u53f0)<\/h3>\n<p>\u9700\u8981\u5f00\u542f\u6293\u5305\u540e\uff0c\u8fdb\u884c\u8bf7\u6c42\u64cd\u4f5c\uff0c\u624d\u4f1a\u6709\u6570\u636e\u5305\u88ab\u6293\u5230<\/p>\n<h4>\u8bf7\u6c42\u65b9\u6cd5<\/h4>\n<ol>\n<li>GET<\/li>\n<li>POST<\/li>\n<\/ol>\n<h3>4.\u5982\u4f55\u627e\u5230\u9700\u8981\u7684\u8d44\u6e90\u5305<\/h3>\n<h4>\u65b9\u6cd5\u4e00\uff1a\u8fc7\u6ee4<\/h4>\n<p>Doc\u4e2d\u7684\u8d44\u6e90\u5305<\/p>\n<h4>\u65b9\u6cd5\u4e8c\uff1a\u641c\u7d22(\u5728\u7a7a\u767d\u5904\u6309<kbd>Ctrl<\/kbd>+<kbd>\u00a0F\u00a0<\/kbd>)<\/h4>\n<h4>\u5bfb\u627e\u6570\u636e\uff0c\u6784\u5efa\u722c\u866b\u7684\u6b65\u9aa4<\/h4>\n<p>\u5206\u6790\u7f51\u7ad9 &#8212;&gt; \u5bfb\u627e\u76ee\u6807\u6570\u636e\u5305 &#8212;&gt; \u6784\u9020\u8bf7\u6c42<\/p>\n<p><font color='red'><strong>\u6ce8\uff1a<\/strong><\/font>\u641c\u7d22\u7684\u8303\u56f4\u53ea\u6709\uff1a<strong>\u54cd\u5e94\u3001\u54cd\u5e94\u5934\u3001\u8bf7\u6c42\u5934<\/strong><\/p>\n<h3>5.\u5982\u4f55\u6784\u9020\u8bf7\u6c42<\/h3>\n<h4>\u72b6\u6001\u7801<\/h4>\n<ul>\n<li>200-300\uff1a\u8bf7\u6c42\u6b63\u5e38<\/li>\n<li>300-400\uff1a\u91cd\u5b9a\u5411<\/li>\n<li>400-500\uff1a\u670d\u52a1\u5668\u95ee\u9898<\/li>\n<li>\u5927\u4e8e\u6216\u7b49\u4e8e500\uff1a\u5ba2\u6237\u7aef\u95ee\u9898<\/li>\n<\/ul>\n<pre><code class=\"language-python\"># \u5bfc\u5165\u6a21\u5757\nimport requests     # \u53d1\u9001\u8bf7\u6c42\u7684\u6a21\u5757\n\nurl = &#039;https:\/\/www.xxsy.net\/&#039;\nheaders = {\n    &#039;user-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&#039;,\n    &#039;referer&#039;:&#039;https:\/\/www.baidu.com\/link?url=suO4Oz7K_kkQ_LRXty3QNX7Y-iCJFCOabR0R_V_z_T_&amp;wd=&amp;eqid=ca9a0fcb006058fc000000066953763c&#039;,\n    &#039;cookie&#039;:&#039;newstatisticUUID=1767077440_8196224563&#039;,\n}\n\n# \u6784\u5efa\u5e76\u53d1\u8d77get\u8bf7\u6c42\nres = requests.get(url=url, headers=headers)\n# res.status_code   # \u67e5\u770b\u72b6\u6001\u7801\nprint(res.status_code)\n# res.text  # \u6253\u5370\u54cd\u5e94\u6587\u672c\u4fe1\u606f\nprint(res.text)\n# res.content    # \u54cd\u5e94\u6570\u636e\u7684\u4e8c\u8fdb\u5236\u5f62\u5f0f\nprint(res.content)\n<\/code><\/pre>\n<h4>\u8bf4\u660e<\/h4>\n<ul>\n<li><code>res.status_code<\/code>\uff1a\u67e5\u770b\u72b6\u6001\u7801<\/li>\n<li><code>res.text<\/code>\uff1a\u54cd\u5e94\u6587\u672c\u4fe1\u606f(\u5b57\u7b26\u4e32\u7c7b\u578b\u6570\u636e)<\/li>\n<li><code>res.content<\/code>\uff1a\u54cd\u5e94\u6570\u636e\u7684\u4e8c\u8fdb\u5236\u5f62\u5f0f(\u6d41\u5a92\u4f53\u6570\u636e)<\/li>\n<\/ul>\n<h4>\u4ee3\u7801\u8fc7\u671f\u95ee\u9898<\/h4>\n<ul>\n<li>\u8eab\u4efd\u95ee\u9898\uff1acookie\u662f\u4f1a\u8fc7\u671f<\/li>\n<\/ul>\n<h4>\u8865\u5145<\/h4>\n<p><strong>\u4e0d\u540c\u7684\u7f51\u7ad9\uff0c\u4ee5\u53ca\u540c\u4e00\u7f51\u7ad9\u4e0d\u540c\u8d44\u6e90\u8def\u5f84\uff0c\u90fd\u53ef\u80fd\u5b58\u5728\u4e0d\u4e00\u6837\u7684\u6821\u9a8c\u65b9\u5f0f<\/strong><\/p>\n<p>\u540c\u4e00\u3001\u76f8\u4f3c\u7684\u8d44\u6e90\u8def\u5f84\u4e0b\u901a\u5e38\u6821\u9a8c\u89c4\u5219\u4e00\u6837<\/p>\n<p>\u6240\u4ee5\u8bf4\u4e00\u822c\u7684\u722c\u866b\u6d41\u7a0b\uff1a\u5206\u6790\u6bcf\u4e00\u4e2a\u9875\u9762\u6240\u9700\u8981\u6784\u5efa\u7684\u8bf7\u6c42\u65b9\u5f0f<\/p>\n<h4>\u4f5c\u4e1a<\/h4>\n<p><strong>\u9700\u6c42\uff1a<\/strong><\/p>\n<ol>\n<li>\u719f\u6089\u6d4f\u89c8\u5668\u6293\u5305\u6d41\u7a0b\uff0c\u5e76\u53ef\u4ee5\u627e\u5230\u76ee\u6807\u8d44\u6e90<\/li>\n<li>\u83b7\u53d6\u51fa\u3010<a href=\"https:\/\/www.xxsy.net\/%E3%80%91%E7%BD%91%E7%AB%99%E4%B8%AD%EF%BC%8C%E6%97%A0%E9%99%90%E8%BF%BD%E4%B9%A6%E6%9D%BF%E5%9D%97%E7%9A%8410%E6%9C%AC%E4%B9%A6%E5%90%8D%EF%BC%8C%E5%B0%86%E4%B9%A6%E5%90%8D%E6%89%93%E5%8D%B0%E5%87%BA%E6%9D%A5(%E9%80%89%E5%81%9A)%EF%BC%8C**%E6%8F%90%E7%A4%BA%EF%BC%9A%E4%BD%BF%E7%94%A8%E6%AD%A3%E5%88%99\">https:\/\/www.xxsy.net\/\u3011\u7f51\u7ad9\u4e2d\uff0c\u65e0\u9650\u8ffd\u4e66\u677f\u5757\u768410\u672c\u4e66\u540d\uff0c\u5c06\u4e66\u540d\u6253\u5370\u51fa\u6765(\u9009\u505a)\uff0c**\u63d0\u793a\uff1a\u4f7f\u7528\u6b63\u5219<\/a>**<\/li>\n<\/ol>\n<pre><code class=\"language-python\"># \u5bfc\u5165\u6a21\u5757\nimport requests     # \u53d1\u9001\u8bf7\u6c42\u7684\u6a21\u5757\n# \u5bfc\u5165\u6b63\u5219\u6a21\u5757\nimport re\n\n\nurl = &#039;https:\/\/www.xxsy.net\/&#039;\nheaders = {\n    &#039;user\t-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&#039;,\n    &#039;referer&#039;:&#039;https:\/\/www.baidu.com\/link?url=suO4Oz7K_kkQ_LRXty3QNX7Y-iCJFCOabR0R_V_z_T_&amp;wd=&amp;eqid=ca9a0fcb006058fc000000066953763c&#039;,\n    &#039;cookie&#039;:&#039;newstatisticUUID=1767077440_8196224563&#039;,\n}\n\n# \u6784\u5efa\u5e76\u53d1\u8d77get\u8bf7\u6c42\nres = requests.get(url=url, headers=headers)\n\n# \u5b9a\u4e49\u6b63\u5219\u67e5\u627e\u6761\u4ef6\nmodule_re = r&#039;&lt;div class=&quot;text-t34 text-l-c-1 font-semibold truncate break-all wrap-word hover:text-l-brand-primary-0 block&quot; data-v-540fce0b&gt;(.*?)&lt;\/div&gt;&#039;\n\nbook_html = re.findall(module_re, res.text)\n\nfor i in range(len(book_html)):\n    print(f&#039;{i+1}.{book_html[i]}&#039;)\n<\/code><\/pre>\n<p><font color='red'><strong>\u6ce8\uff1a<\/strong><\/font>\u6709\u4e9b\u7f51\u7ad9\u5f53\u4e2d\u7684\u5c5e\u6027\u503c\u4ee5\u53ca\u6807\u7b7e\uff0c\u662f\u7531\u4e8e\u3001\u6846\u67b6\u8fdb\u884c\u8bbe\u7f6e\u7684\uff0c\u5b58\u5728\u4e0d\u786e\u5b9a\u6027\uff0c\u6240\u4ee5\u5177\u4f53\u7684\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5199\u6cd5\uff0c\u9700\u6839\u636e\u4ee3\u7801\u5f53\u4e2d\u7684\u54cd\u5e94\u5185\u5bb9\u6765\u8fdb\u884c<\/p>\n<h2>\u4e09\u3001\u767b\u5f55\u6d41\u7a0b\u5206\u6790<\/h2>\n<h3>1.\u6743\u8bc1\u6d41<\/h3>\n<p><strong>\u6743\u9650<\/strong>(VIP)\u3001<strong>\u51ed\u8bc1<\/strong>(\u662f\u5426\u767b\u5f55)<\/p>\n<h3>2.\u767b\u5f55\u6d41\u7a0b\u5206\u6790<\/h3>\n<h4>\u9650\u6d41\u95ee\u9898<\/h4>\n<p><strong>\u5355\u4e00\u65f6\u95f4\u6bb5\u5185\uff0c\u9650\u5236\u540c\u4e00IP\u3001\u7528\u6237\u7684\u8bbf\u95ee(\u8bf7\u6c42)\u6b21\u6570<\/strong><\/p>\n<h4>\u6d4b\u8bd5\u7f51\u5740<\/h4>\n<ul>\n<li>\u7b14\u8da3\u9601\u767b\u5f551<br \/><a href=\"https:\/\/www.bqgam.com\/user\/login.html\">https:\/\/www.bqgam.com\/user\/login.html<\/a><\/li>\n<\/ul>\n<h4>\u5982\u4f55\u5feb\u6377\u7684\u627e\u5230\u767b\u5f55\u76ee\u6807\u8d44\u6e90\u5305<\/h4>\n<ol>\n<li>\u901a\u8fc7\u641c\u7d22\u5173\u952e\u5b57\uff1alogin\u3001submit<\/li>\n<li>\u901a\u8fc7\u6d4f\u89c8\u5668\u624b\u52a8\u8fc7\u6ee4\u51fa\u4e00\u4e9b\u5e38\u89c1\u7684\u8d44\u6e90\u5305 <\/li>\n<li>\u7b2c\u4e09\u65b9\u6293\u5305\u5de5\u5177<\/li>\n<\/ol>\n<p><strong>\u4ee3\u7801<\/strong><\/p>\n<pre><code class=\"language-python\">import requests\n\n# \u8bf7\u6c42\u5730\u5740\nurl = &#039;https:\/\/www.bqgam.com\/user\/action.html&#039;\n# \u8bf7\u6c42\u5934\u5185\u5bb9\nheaders = {\n    &#039;Host&#039;: &#039;www.bqgam.com&#039;,\n    &#039;Content-Type&#039;: &#039;application\/x-www-form-urlencoded; charset=UTF-8&#039;,\n    &#039;User-Agent&#039;: &#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&#039;,\n}\n\n# \u8d1f\u8f7d\ndata = &#039;action=login&amp;username=19896223228&amp;password=wzw200508&#039;\n\n# \u53d1\u8d77\u8bf7\u6c42\nres = requests.post(url=url, headers=headers, data=data)\nprint(res.text)\n<\/code><\/pre>\n<h3>3.\u590d\u6742\u767b\u5f55\u6d41\u7a0b\u5206\u6790<\/h3>\n<h4>\u6d4b\u8bd5\u7f51\u7ad9<\/h4>\n<ul>\n<li>\n<p>\u5929\u4e0b\u4e66\u76df<\/p>\n<p><a href=\"http:\/\/www.fbook.net\/\">http:\/\/www.fbook.net\/<\/a><\/p>\n<\/li>\n<\/ul>\n<h4>\u590d\u6742\u767b\u5f55\u6d41\u7a0b\u5206\u6790<\/h4>\n<p><kbd>\u8f93\u5165\u7528\u6237\u540d\u5bc6\u7801 <\/kbd>&#8212;&gt; <kbd>\u6821\u9a8c<\/kbd> &#8212;&gt; <kbd>\u767b\u5f55<\/kbd><\/p>\n<h4>\u56fe\u7247\u9a8c\u8bc1\u7801\u539f\u7406<\/h4>\n<p>\u5c31\u662f\u6bcf\u4e2a\u9a8c\u8bc1\u7801\u90fd\u4f1a\u6709\u4e00\u4e2a\u72ec\u81ea\u7684ID\u503c\uff0c\u8fd9\u4e2aid\u503c\u8ddf\u5f53\u524d\u9a8c\u8bc1\u7801\u7684\u7ed3\u679c\u7ec4\u6210\u4e00\u4e2a\u952e\u503c\u5bf9\uff0c\u63d0\u4ea4\u8bf7\u6c42\u65f6\uff0c\u4f1a\u81ea\u52a8\u643a\u5e26\u56fe\u7247\u9a8c\u8bc1\u7801\u7684ID\uff0c\u4ece\u800c\u6821\u9a8c\u63d0\u4ea4\u7684\u9a8c\u8bc1\u7801\u662f\u5426\u4e0e\u952e\u503c\u5bf9\u5f53\u4e2d\u7684\u9a8c\u8bc1\u7801\u4e00\u81f4<\/p>\n<ul>\n<li><code>Cookie:Hm_lvt_60b7389344d5e30b600d3767cdf28d50=1767158046,1767158565,1767159422; Hm_lpvt_60b7389344d5e30b600d3767cdf28d50=1767159422; HMACCOUNT=306E98BBEBC08A58<\/code><\/li>\n<li><code>Cookie:Hm_lvt_60b7389344d5e30b600d3767cdf28d50=1767158046,1767158565,1767159422; HMACCOUNT=306E98BBEBC08A58; ASP.NET_SessionId=pvcyfaa0uywkwb2qh3gbv5hp; Hm_lpvt_60b7389344d5e30b600d3767cdf28d50=1767159429<\/code><\/li>\n<\/ul>\n<h4><strong>\u5b9e\u6218<\/strong><\/h4>\n<pre><code class=\"language-python\">import requests\n\n# http:\/\/www.fbook.net\/Member\/Captcha?t=0.10251672893148756\n# \u9a8c\u8bc1\u7801\u56fe\u7247\u5730\u5740\ncode_url = &#039;http:\/\/www.fbook.net\/Member\/Captcha&#039;\ncode_res = requests.get(code_url)\n\n# \u5c06\u9a8c\u8bc1\u7801\u56fe\u7247\u4fdd\u5b58\u5230\u6307\u5b9a\u6587\u4ef6\u5939\nwith open(&#039;\u9a8c\u8bc1\u7801\u56fe\u7247\/code_01.gif&#039;, &#039;wb&#039;) as f:\n    f.write(code_res.content)\n\n# \u767b\u5f55\n# \u767b\u5f55\u7f51\u5740\nlogin_url = &#039;http:\/\/www.fbook.net\/Member\/Login\/&#039;\n# \u767b\u5f55\u8bf7\u6c42\u5934\nlogin_headers = {\n    &#039;Content-Type&#039;: &#039;application\/x-www-form-urlencoded; charset=UTF-8&#039;,\n    &#039;Cookie&#039;: f&#039;ASP.NET_SessionId={code_res.cookies.get(&quot;ASP.NET_SessionId&quot;)}; Hm_lvt_60b7389344d5e30b600d3767cdf28d50=1767158046,1767158565,1767159422,1767173244; HMACCOUNT=306E98BBEBC08A58; max=AFA58E2DD36DBFADB7F80B766ADEA6A55691F5404576EF7CA6C692327A33F85DB04FDD8E2067594506B40884CA3D81C28EB30E02A47544B9A6DFEF889CFF8F371A5FA4AA1652CFF41A7FBD4E3FD4626647FB2815E376FF70D111A75692B1292A0F91CB6F6DB41F697FA1A67130D8327C6E4BAB22; Hm_lpvt_60b7389344d5e30b600d3767cdf28d50=1767173476&#039;,\n}\n# \u767b\u5f55\u8d1f\u8f7d\nlogin_data = f&#039;loginName=huihuia24&amp;loginPass=wzw200508&amp;captcha={input(&quot;\u8bf7\u8f93\u5165\u9a8c\u8bc1\u7801\uff1a&quot;)}&#039;\n\n# \u767b\u5f55\u5e76\u53d1\u9001\u8bf7\u6c42\nlogin_res = requests.post(url=login_url, headers=login_headers, data=login_data)\n# \u8f93\u51fa\u7ed3\u679c\nprint(login_res.text)\n<\/code><\/pre>\n<h2>\u56db\u3001IP\u4ee3\u7406<\/h2>\n<h3>1.\u4ee3\u7406\u7f51\u5740<\/h3>\n<ol>\n<li>\u7ad9\u5927\u7237-\u514d\u8d39\u4ee3\u7406\uff1a<a href=\"https:\/\/www.zdaye.com\/free\/\"><font color='#b0ffff'>\u70b9\u51fb\u6b64\u5904<\/font><\/a><\/li>\n<li>\u4e2d\u56fd-\u514d\u8d39\u5728\u7ebf\u4ee3\u7406\u5217\u8868(<strong>\u9700\u6ce8\u518c\uff0c\u9ebb\u70e6<\/strong>)\uff1a<a href=\"https:\/\/cn.proxy-tools.com\/proxy\/cn\"><font color='#b0ffff'>\u70b9\u51fb\u6b64\u5904<\/font><\/a><\/li>\n<li>\u5f00\u5fc3\u4ee3\u7406\uff1a<a href=\"http:\/\/www.kxdaili.com\/dailiip.html\"><font color='#b0ffff'>\u70b9\u51fb\u6b64\u5904<\/font><\/a><\/li>\n<li>\u65e0\u5fe7\u4ee3\u7406IP\uff1a<a href=\"https:\/\/www.data5u.com\/\"><font color='#b0ffff'>\u70b9\u51fb\u6b64\u5904<\/font><\/a><\/li>\n<\/ol>\n<h3>2.\u4ee3\u7406\u7684\u539f\u7406<\/h3>\n<h4>\u4ec0\u4e48\u60c5\u51b5\u4f1a\u4f7f\u7528\u4ee3\u7406<\/h4>\n<ol>\n<li>\u81ea\u5df1\u7684\u4e3b\u673a\u88ab\u7f51\u7ad9\u9650\u6d41\u4e86<\/li>\n<li>\u4e0d\u60f3\u66b4\u9732\u81ea\u5df1\u7684ip\u7684\u65f6\u5019<\/li>\n<\/ol>\n<blockquote>\n<p>\u83b7\u53d6\u4e00\u4e2a\u4ee3\u7406\u670d\u52a1\u5668\uff0c\u8f6c\u53d1\u6211\u4eec\u7684\u8bf7\u6c42\u4ee5\u53ca\u56de\u4f20\u7684\u54cd\u5e94<\/p>\n<\/blockquote>\n<h4>\u539f\u7406<\/h4>\n<p><kbd>\u4e3b\u673a<\/kbd>&#8212;-\u53d1\u8d77\u8bf7\u6c42&#8211;&gt;<kbd>\u4ee3\u7406<\/kbd>&#8212;-\u8f6c\u53d1\u8bf7\u6c42&#8211;&gt;<kbd>\u670d\u52a1\u5668<\/kbd><br \/><kbd>\u4e3b\u673a<\/kbd>&lt;&#8211;\u8f6c\u53d1\u54cd\u5e94&#8212;-<kbd>\u4ee3\u7406<\/kbd>&lt;&#8211;\u56de\u4f20\u54cd\u5e94&#8212;-<kbd>\u670d\u52a1\u5668<\/kbd><\/p>\n<h3>3.\u4ee3\u7406\u7684\u4f7f\u7528<\/h3>\n<h4>Chrome\u6d4f\u89c8\u5668\u4f7f\u7528\u4ee3\u7406<\/h4>\n<p><font color='red'><strong>\u6ce8\uff1a<\/strong><\/font>\u5728\u4f7f\u7528\u4ee3\u7406\u524d\u9700\u8981\u5173\u95ed\u6240\u6709\u6b63\u5728\u8fd0\u884c\u7684Google\u6d4f\u89c8\u5668\u7a97\u53e3\uff0c\u5426\u5219\u4ee3\u7406\u65e0\u6548<\/p>\n<p>\u6253\u5f00cmd\u901a\u8fc7\u547d\u4ee4\uff1a<\/p>\n<pre><code class=\"language-shell\">chrome --proxy-server=\u4ee3\u7406ip:\u7aef\u53e3\u53f7\n<\/code><\/pre>\n<p><strong>\u4f8b:<\/strong><\/p>\n<pre><code class=\"language-shell\">Chrome --proxy-server=210.16.160.222:7890\n<\/code><\/pre>\n<h3>4.python\u4f7f\u7528\u4ee3\u7406<\/h3>\n<h4>\u793a\u4f8b<\/h4>\n<pre><code class=\"language-python\">import requests\n\n# \u4f7f\u7528\u4ee3\u7406\u8bbf\u95eehttps:\/\/www.xxsy.net\/\nurl = &#039;https:\/\/www.xxsy.net\/&#039;\n\nheaders = {\n    &quot;User-Agent&quot;: &quot;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&quot;,\n}\n\n# \u914d\u7f6e\u4ee3\u7406\nproxy = {\n    &#039;http&#039;: &#039;http:\/\/210.16.160.222:7890&#039;,\n    &#039;https&#039;: &#039;http:\/\/210.16.160.222:7890&#039;,\n}\n\nres = requests.get(url=url, headers=headers, proxies=proxy)\nprint(res.text)\n<\/code><\/pre>\n<blockquote>\n<p>IP\u6c60\u7684\u4f7f\u7528\uff1a\u642d\u5efa\u4ee3\u7406\u6c60&#8212;-\u6839\u636e\u4ee3\u7406IP\u65f6\u957f\u6765\u8fdb\u884c\u8bbe\u8ba1\u4f7f\u7528\u6d41\u7a0b<\/p>\n<\/blockquote>\n<h3>5.\u642d\u5efaip\u4ee3\u7406\u6c60<\/h3>\n<h4>\u4ee3\u7406\u6c60\u7684\u6821\u9a8c\u65b9\u5f0f<\/h4>\n<ol>\n<li>\u4f7f\u7528\u524d\u6821\u9a8c\n<ul>\n<li>\u9002\u5408\u5728\u4ee3\u7406ip\u63d0\u4f9b\u5546\u63d0\u4f9b\u7684\u4ee3\u7406ip\u8d28\u91cf\u4e0d\u662f\u5f88\u597d\u7684\u60c5\u51b5\u4e0b\u4f7f\u7528\uff0c\u6b64\u65b9\u6cd5\u6765\u63d0\u9ad8\u4f60\u7684\u4ee3\u7406IP\u7684\u53ef\u9760\u6027<\/li>\n<\/ul>\n<\/li>\n<li>\u4f7f\u7528\u65f6\u6821\u9a8c\n<ul>\n<li>\u4f7f\u7528\u5728\u4ee3\u7406IP\u63d0\u4f9b\u5546\u63d0\u4f9b\u7684\u4ee3\u7406IP\u8d28\u91cf\u8db3\u591f\u9ad8\u7684\u65f6\u5019\u4f7f\u7528\uff0c\u6b64\u65b9\u6cd5\u6765\u8282\u7701\u65f6\u95f4<\/li>\n<li>\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0c\u6b64\u65b9\u6cd5\u4f1a\u5bfc\u81f4\u5b50\u554a\u6570\u636e\u722c\u53d6\u5de5\u7a0b\u4e2d\u5bfc\u81f4\u6570\u636e\u4e22\u5931\uff0c\u56e0\u6b64\u9700\u8981\u5bf9\u51fa\u95ee\u9898\u7684\u5730\u65b9\u8fdb\u884c\u6807\u8bc6\u6216\u8bb0\u5f55\uff0c\u7136\u540e\u5728\u4ee3\u7801\u8fd0\u884c\u540e\u5bf9\u6807\u8bc6\u6216\u8bb0\u5f55\u7684\u4e22\u5931\u4f4d\u7f6e\u8fdb\u884c\u91cd\u65b0\u91c7\u96c6<\/li>\n<\/ul>\n<\/li>\n<\/ol>\n<h4>IP\u6c60\u7684\u4f7f\u7528<\/h4>\n<p>\u642d\u5efa\u4ee3\u7406\u6c60&#8211;&gt;\u6839\u636e\u4ee3\u7406IP\u65f6\u957f\u6765\u8fdb\u884c\u8bbe\u8ba1\u4f7f\u7528<\/p>\n<ol>\n<li>\n<p>\u9488\u5bf9\u77ed\u6548IP<\/p>\n<p>\u4f7f\u7528<code>redis<\/code>\u6570\u636e\u5e93\u6765\u8fdb\u884c\u5b58\u50a8\u6b64\u7c7bIP\uff0c\u5e76\u4e14\u8bbe\u7f6e\u5bf9\u5e94\u7684\u6709\u6548\u65f6\u957f<\/p>\n<\/li>\n<li>\n<p>\u957f\u6548IP<\/p>\n<p>\u4f7f\u7528\u672c\u5730\u6587\u4ef6\u7684\u5f62\u5f0f\u8fdb\u884c\u5b58\u50a8\uff0c<\/p>\n<\/li>\n<\/ol>\n<blockquote>\n<p>\u4e0d\u7ba1\u4ee5\u4e0a\u4e24\u79cdIP\u90fd\u9700\u8981\u6839\u636e\u5b83\u7684\u6709\u6548\u65f6\u957f\u6765\u8fdb\u884c\u5408\u7406\u7684\u4ee3\u7406IP\u66f4\u65b0<\/p>\n<\/blockquote>\n<h2>\u4e94\u3001\u6279\u91cf\u722c\u53d6\u548c\u7ffb\u9875\u89c4\u5219\u5206\u6790<\/h2>\n<p><strong>\u6848\u4f8b\u7f51\u5740\uff1a<a href=\"https:\/\/cs.loupan.com\/\"><font color='#b0ffff'>\u70b9\u51fb\u6b64\u5904<\/font><\/a><\/strong><\/p>\n<h3>1.\u7ffb\u9875\u89c4\u5219<\/h3>\n<h4>\u697c\u76d8\u7f51&#8212;-\u65b0\u623f\u9875\u9762\u7ffb\u9875\u89c4\u5219<\/h4>\n<p>\u4e3b\u8d44\u6e90\u8def\u5f84(<code>https:\/\/cs.loupan.com\/xinfang\/<\/code>)+(<code>pn<\/code>)\uff0cn\u4e3a\u6570\u5b571-97\u6765\u8fdb\u884c\u7ffb\u9875\u66f4\u65b0\u6570\u636e<\/p>\n<ul>\n<li>\u7b2c\u4e00\u9875\u7f51\u5740\uff1a<a href=\"https:\/\/cs.loupan.com\/xinfang\/\">https:\/\/cs.loupan.com\/xinfang\/<\/a><\/li>\n<li>\u7b2c\u4e8c\u9875\u7f51\u5740\uff1a<a href=\"https:\/\/cs.loupan.com\/xinfang\/p2\/\">https:\/\/cs.loupan.com\/xinfang\/p2\/<\/a><\/li>\n<li>\u7b2c\u4e09\u9875\u7f51\u5740\uff1a<a href=\"https:\/\/cs.loupan.com\/xinfang\/p3\/\">https:\/\/cs.loupan.com\/xinfang\/p3\/<\/a><\/li>\n<\/ul>\n<h4>\u697c\u76d8\u7f51&#8212;-\u5546\u4e1a\u5730\u4ea7\u9875\u9762\u7ffb\u9875\u89c4\u5219<\/h4>\n<p>\u4e3b\u8d44\u6e90\u8def\u5f84(<code>https:\/\/cs.loupan.com\/business\/<\/code>)+(<code>pn<\/code>)\uff0cn\u4e3a\u6570\u5b571-22\u6765\u8fdb\u884c\u7ffb\u9875\u66f4\u65b0\u6570\u636e<\/p>\n<h4>\u793a\u4f8b<\/h4>\n<p>\u83b7\u53d6\u7ad9\u957f\u7d20\u6750(<a href=\"https:\/\/sc.chinaz.com\/tupian\/\"><font color='#b0ffff'>\u94fe\u63a5<\/font><\/a>)&#8212;-\u56fe\u7247\u9875\u9762\u7684\u524d\u4e94\u9875\u6570\u636e<\/p>\n<pre><code class=\"language-python\"># \u5bfc\u5165\u6a21\u5757\nimport requests\n\n# \u8bf7\u6c42\u5934\u5185\u5bb9\nheaders = {\n    &#039;cookie&#039;:&#039;_clck=l8ww91%5E2%5Eg2h%5E0%5E2196; _clsk=7urkiw%5E1767681834863%5E8%5E1%5Ev.clarity.ms%2Fcollect&#039;,\n    &#039;user-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&#039;,\n    &#039;referer&#039;:&#039;https:\/\/sc.chinaz.com\/jianli\/&#039;,\n}\n\ndef zhanzhang_tupian():\n    # \u8bbe\u7f6e\u722c\u53d6\u8303\u56f41-5\n    for i in range(1,6):\n        # \u6839\u636e\u7ffb\u9875\u89c4\u5219\u5b9a\n        if i == 1:\n            tupian_url = &#039;https:\/\/sc.chinaz.com\/tupian\/&#039;\n        else:\n            tupian_url = f&#039;https:\/\/sc.chinaz.com\/tupian\/index_{i}.html&#039;\n        # \u4ee3\u7406IP\n        proxy = {\n            &#039;http&#039;: &#039;120.92.212.16:8890&#039;,\n            &#039;https&#039;: &#039;120.92.212.16:8890&#039;,\n        }\n        # \u53d1\u8d77\u8bf7\u6c42\n        tupian_res = requests.get(url=tupian_url, headers=headers, proxies=proxy)\n        # \u8bbe\u7f6e\u7f16\u7801\u683c\u5f0f\u9632\u6b62\u4e71\u7801\n        tupian_res.encoding = &#039;UTF-8&#039;\n        # \u77ed\u70b9\u5904\n        tupian_res\n\nif __name__ == &#039;__main__&#039;:\n    zhanzhang_tupian()\n<\/code><\/pre>\n<blockquote>\n<p><strong>\u8865\u5145<\/strong><\/p>\n<p>\u5f53\u6211\u4eec\u53bb\u6279\u91cf\u722c\u53d6\u6570\u636e\u7684\u65f6\u5019\uff0c\u9700\u8981\u975e\u5e38\u6ce8\u610f\u7f51\u7ad9\u7684\u9650\u6d41\u95ee\u9898<\/p>\n<ol>\n<li>\u4f7f\u7528\u4ee3\u7406&#8212;-\u51cf\u5c11\u5355\u4e00IP\u7684\u8fc7\u91cf\u8bbf\u95ee<\/li>\n<li>\u6dfb\u52a0\u7b49\u5f85\u65f6\u95f4&#8212;-\u9632\u6b62\u5355\u4e00IP\u5728\u4e00\u4e2a\u65f6\u95f4\u6bb5\u5185\u8bbf\u95ee\u9891\u7387\u8fc7\u9ad8<\/li>\n<\/ol>\n<\/blockquote>\n<h3>2.\u65e0\u7279\u5b9a\u89c4\u5219\u7ffb\u9875\u5206\u6790<\/h3>\n<p>\u6f47\u6e58\u4e66\u9662(<a href=\"https:\/\/www.xxsy.net\/\"><font color='#b0ffff'>\u94fe\u63a5<\/font><\/a>)<\/p>\n<blockquote>\n<p><strong>\u7b2c\u4e00\u672c\u4e66<\/strong><\/p>\n<p>\u7b2c\u4e00\u9875\uff1a<a href=\"https:\/\/www.xxsy.net\/chapter\/25866531901067904\/69470529228165448\">https:\/\/www.xxsy.net\/chapter\/25866531901067904\/69470529228165448<\/a><br \/>\u7b2c\u4e8c\u9875\uff1a<a href=\"https:\/\/www.xxsy.net\/chapter\/25866531901067904\/69474434292962500\">https:\/\/www.xxsy.net\/chapter\/25866531901067904\/69474434292962500<\/a><\/p>\n<p><strong>\u7b2c\u4e8c\u672c\u4e66<\/strong><\/p>\n<p>\u7b2c\u4e00\u9875\uff1a<a href=\"https:\/\/www.xxsy.net\/chapter\/26169087201414504\/70256336176203430\">https:\/\/www.xxsy.net\/chapter\/26169087201414504\/70256336176203430<\/a><br \/>\u7b2c\u4e8c\u9875\uff1a<a href=\"https:\/\/www.xxsy.net\/chapter\/26169087201414504\/70256433886714439\">https:\/\/www.xxsy.net\/chapter\/26169087201414504\/70256433886714439<\/a><\/p>\n<\/blockquote>\n<h4>\u5c42\u7ea7\u722c\u53d6<\/h4>\n<p>\u4e66\u7c4d\u7ae0\u8282\u76ee\u5f55\uff1a<a href=\"https:\/\/www.xxsy.net\/chapterlist\/\">https:\/\/www.xxsy.net\/chapterlist\/<\/a> +\u4e66\u7c4d\u7f16\u53f7<br \/>\u4e66\u7c4d\u7ae0\u8282\u5185\u5bb9\uff1a<a href=\"https:\/\/www.xxsy.net\/chapter\/\">https:\/\/www.xxsy.net\/chapter\/<\/a> +\u4e66\u7c4d\u7f16\u53f7+\u4e66\u7c4d\u7ae0\u8282\u7f16\u53f7<\/p>\n<p><strong>\u793a\u4f8b<\/strong><\/p>\n<pre><code class=\"language-python\"># \u5bfc\u5165\u6a21\u5757\nimport requests     # \u53d1\u9001\u8bf7\u6c42\u7684\u6a21\u5757\n# \u5bfc\u5165\u6b63\u5219\u6a21\u5757\nimport re\n\n\nurl = &#039;https:\/\/www.xxsy.net\/&#039;\nheaders = {\n    &#039;user\t-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&#039;,\n    &#039;referer&#039;:&#039;https:\/\/www.xxsy.net\/&#039;,\n    &#039;cookie&#039;:&#039;newstatisticUUID=1767077440_8196224563&#039;,\n}\n\n# \u6784\u5efa\u5e76\u53d1\u8d77get\u8bf7\u6c42\nres = requests.get(url=url, headers=headers)\n# \u83b7\u53d6\u699c\u5355\u4e2d\u4e66\u7684ID\nrank_book_list = re.findall(r&#039;&lt;a href=&quot;\/book\/(d{14,17})&quot; target=&quot;_blank&quot;&gt;.*?&lt;\/a&gt;&#039;,res.text)[-30:]\n\nrank_chapter_dict = dict()\nfor i in rank_book_list[:5]:\n    chapter_url = f&#039;https:\/\/www.xxsy.net\/chapterlist\/{i}&#039;\n    chapter_res = requests.get(url=chapter_url, headers=headers)\n    # \u83b7\u53d6\u6bcf\u4e2a\u7ae0\u8282\u7684ID\n    chapter_list = re.findall(r&#039;&lt;a href=&quot;\/chapter(.*?)&quot; target=&quot;_blank&quot; title=&quot;.*?&quot; style=&quot;padding:8px 0;display:flex;&quot;&gt;&#039;,chapter_res.text)[0:10]\n    chapter_list[0] = re.search(r&#039;\/chapter(.*)&#039;,chapter_list[0][-50:]).group(1)\n    rank_chapter_dict[i] = chapter_list\n\nfor key in rank_chapter_dict:\n    for chapter_id in rank_chapter_dict[key]:\n        chapter_url = f&#039;https:\/\/www.xxsy.net\/chapter{chapter_id}&#039;\n        chapter_res_if = requests.get(url=chapter_url, headers=headers)\n        # \u83b7\u53d6\u6807\u9898\n        title = re.findall(r&#039;&lt;h1 .*?&gt;(.*?)&lt;\/h1&gt;&#039;, chapter_res_if.text)[0]\n        # \u83b7\u53d6\u5185\u5bb9\n        book_text = tuple(map(lambda x:x+&#039;n&#039;,re.findall(r&#039;&lt;p&gt;(.*?)&lt;\/p&gt;&#039;,chapter_res_if.text)))\n        # \u50a8\u5b58\u81f3\u6587\u4ef6\n        with open(f&#039;book\/{key}.txt&#039;,&#039;a&#039;,encoding=&#039;utf-8&#039;) as f:\n            f.write(title+&#039;n&#039;)\n            f.writelines(book_text)\n<\/code><\/pre>\n<p><strong>\u6d41\u7a0b<\/strong>\uff1a\u83b7\u53d6\u4e66\u7c4d\u7f16\u53f7&#8211;&gt;\u83b7\u53d6\u5bf9\u5e94\u4e66\u7c4d\u7684\u7ae0\u8282&#8211;&gt;\u83b7\u53d6\u7ae0\u8282\u4e2d\u7684\u5177\u4f53\u5185\u5bb9<\/p>\n<h4>\u62d3\u5c55<\/h4>\n<p><code>map()<\/code>\u51fd\u6570<\/p>\n<p>map\u51fd\u6570\u662f\u7528\u6765\u7edf\u4e00\u4fee\u6539\u53ef\u8fed\u4ee3\u7c7b\u578b\u7684\u51fd\u6570<\/p>\n<pre><code class=\"language-python\">test_list = [1,2,3,4,5,6]\ntest_list_new = list(map(lambda x:x+1,test_list))\n<\/code><\/pre>\n<h3>3.\u9488\u5bf9\u641c\u7d22\u89c4\u5219\u6279\u91cf\u722c\u53d6\u5206\u6790<\/h3>\n<p>\u7ecf\u8fc7\u5206\u6790\uff0c\u7f51\u7ad9\u6570\u636e\u662f\u6839\u636e\u641c\u7d22\u5185\u5bb9\u6765\u8fdb\u884c\u7ffb\u9875\u83b7\u53d6\u89c4\u5219\u7684<\/p>\n<h2>\u516d\u3001\u6b63\u5219\u89e3\u6790<\/h2>\n<h3>1.\u9ad8\u9636\u51fd\u6570<\/h3>\n<h4>map<\/h4>\n<p><strong>\u7edf\u4e00\u64cd\u4f5c\u51fd\u6570<\/strong><\/p>\n<p>\u8bed\u6cd5\uff1a<code>map(\u5904\u7406\u51fd\u6570,\u53ef\u8fed\u4ee3\u7c7b\u578b)<\/code><\/p>\n<p>map\u8fd4\u56de\u7684\u662f\u4e00\u4e2a\u53ef\u8fed\u4ee3\u7684map\u5bf9\u8c61<\/p>\n<p><font color='red'><strong>\u6ce8\uff1a<\/strong><\/font>map\u5bf9\u8c61\u662f\u4e0d\u53ef\u67e5\u770b\u7684\uff0c\u9700\u8981\u8f6c\u5316\u4e3a\u5e8f\u5217\u7c7b\u578b\u624d\u53ef\u89c1\uff08\u5217\u8868\u3001\u96c6\u5408\u3001\u5143\u7ec4\uff09<\/p>\n<p>map\u51fd\u6570\u662f\u7528\u6765\u7edf\u4e00\u4fee\u6539\u53ef\u8fed\u4ee3\u7c7b\u578b\u7684\u51fd\u6570<\/p>\n<pre><code class=\"language-python\">test_list = [1,2,3,4,5,6]\ntest_list_new = list(map(lambda x:x+1,test_list))\n<\/code><\/pre>\n<h4>zip<\/h4>\n<p><strong>\u5c06\u4e24\u4e2a\u53c2\u6570\u5408\u5e76\u4e3a\u4e00\u4e2aitem\u5bf9\u8c61(\u7ec4\u5408)<\/strong><\/p>\n<p>\u8bed\u6cd5\uff1a<code>zip(\u5e8f\u5217\u7c7b\u578b1(\u53ef\u4ee5\u5305\u542b\u96c6\u5408),\u5e8f\u5217\u7c7b\u578b2(\u53ef\u4ee5\u5305\u542b\u96c6\u5408))<\/code>-&gt;\u5408\u5e76\u51fd\u6570<\/p>\n<p><font color='red'><strong>\u6ce8\uff1a<\/strong><\/font>\u4e24\u4e2a\u53c2\u6570\u7684\u5143\u7d20\u4e2a\u6570\u5fc5\u987b\u4e00\u81f4<\/p>\n<p>zip\u8fd4\u56de\u4e00\u4e2azip\u5bf9\u8c61\uff0c\u9700\u8981\u8f6c\u6362\u4e3a\u53ef\u89c1\u5bf9\u8c61-&gt;list\/tuple\/dict\/set<\/p>\n<pre><code class=\"language-python\">list1 = [1,2,3,4,5]\nlist2 = [&#039;a&#039;,&#039;b&#039;,&#039;c&#039;,&#039;d&#039;,&#039;e&#039;]\nzipped1 = tuple(zip(list1,list2))\nzipped2 = list(zip(list1,list2))\nzipped3 = dict(zip(list1,list2))\nzipped4 = set(zip(list1,list2))\nprint(zipped1)\nprint(zipped2)\nprint(zipped3)\nprint(zipped4)\n&quot;&quot;&quot;\n((1, &#039;a&#039;), (2, &#039;b&#039;), (3, &#039;c&#039;), (4, &#039;d&#039;), (5, &#039;e&#039;))\n[(1, &#039;a&#039;), (2, &#039;b&#039;), (3, &#039;c&#039;), (4, &#039;d&#039;), (5, &#039;e&#039;)]\n{1: &#039;a&#039;, 2: &#039;b&#039;, 3: &#039;c&#039;, 4: &#039;d&#039;, 5: &#039;e&#039;}\n{(1, &#039;a&#039;), (3, &#039;c&#039;), (5, &#039;e&#039;), (2, &#039;b&#039;), (4, &#039;d&#039;)}\n&quot;&quot;&quot;\n<\/code><\/pre>\n<h4>filter<\/h4>\n<p><strong>\u8fc7\u6ee4\u51fd\u6570<\/strong><\/p>\n<p>\u8bed\u6cd5\uff1a<code>filter(\u8fc7\u6ee4\u51fd\u6570,\u5e8f\u5217\u7c7b\u578b(\u5305\u542b\u96c6\u5408))<\/code><\/p>\n<p>filter\u8fd4\u56de\u4e00\u4e2afilter\u5bf9\u8c61\uff0c\u4e0d\u53ef\u89c1\uff0c\u9700\u8981\u8f6c\u6362\u4e3a\u53ef\u89c1\u5bf9\u8c61<\/p>\n<pre><code class=\"language-python\">list_test = [345,454,455,322,456,754]\nnew_list = filter(lambda x:x&gt;400,list_test)\nprint(list(new_list))\n\n&quot;&quot;&quot;\n[454, 455, 456, 754]\n&quot;&quot;&quot;\n<\/code><\/pre>\n<h4>enumerate<\/h4>\n<p><strong>\u679a\u4e3e\u51fd\u6570<\/strong><\/p>\n<p>\u8bed\u6cd5\uff1a<code>enumerate(\u5e8f\u5217\u7c7b\u578b(\u4e0d\u5305\u542b\u96c6\u5408))<\/code><\/p>\n<p>\u5c06\u5e8f\u5217\u7c7b\u578b\u91cc\u9762\u7684\u6570\u636e\u4e0e\u5b83\u6240\u5bf9\u5e94\u7684\u4e0b\u6807\u8fdb\u884c\u7ec4\u5408\uff0c\u8fd4\u56de\u4e00\u4e2a\u5bf9\u5e94\u7684item\uff0c<\/p>\n<p>\u8fd4\u56deenumerate\u5bf9\u8c61\uff0c\u4e0d\u53ef\u89c1\uff0c\u9700\u8f6c\u6362\u4e3a\u5e8f\u5217\u7c7b\u578b<\/p>\n<pre><code class=\"language-python\">list_test = [345,454,455,322,456,754]\nnew_list1 = tuple(enumerate(list_test))\nnew_list2 = list(enumerate(list_test))\nnew_list3 = dict(enumerate(list_test))\nnew_list4 = set(enumerate(list_test))\nprint(new_list1)\nprint(new_list2)\nprint(new_list3)\nprint(new_list4)\n\n&quot;&quot;&quot;\n((0, 345), (1, 454), (2, 455), (3, 322), (4, 456), (5, 754))\n[(0, 345), (1, 454), (2, 455), (3, 322), (4, 456), (5, 754)]\n{0: 345, 1: 454, 2: 455, 3: 322, 4: 456, 5: 754}\n{(0, 345), (5, 754), (3, 322), (4, 456), (1, 454), (2, 455)}\n&quot;&quot;&quot;\n<\/code><\/pre>\n<h3>2.\u6b63\u5219\u89e3\u6790<\/h3>\n<p><code>s<\/code>\uff1a\u5339\u914d\u6362\u884c\u7b26&#8211;&gt;\u56e0\u4e3a\u901a\u914d\u7b26<code>.<\/code>\u65e0\u6cd5\u5339\u914d\u6362\u884c<\/p>\n<p><code>?<\/code>\uff1a\u53d6\u6d88\u8d2a\u5a6a\u6a21\u5f0f&#8211;&gt;\u4e3a\u4e86\u9632\u6b62\u8fc7\u591a\u7684\u83b7\u53d6\u5185\u5bb9<\/p>\n<p>\u4f8b\uff1a<\/p>\n<pre><code class=\"language-python\"># \u5185\u5bb9\n&lt;h1&gt;asjdhfkjash&lt;\/h1&gt;\n# \u8d2a\u5a6a\u6a21\u5f0f\n&lt;.*&gt; ---&gt; &lt;h1&gt;asjdhfkjash&lt;\/h1&gt;\n# \u53d6\u6d88\u8d2a\u5a6a\u6a21\u5f0f\n&lt;.*?&gt; --&gt; &lt;h1&gt;,&lt;\/h1&gt;\n<\/code><\/pre>\n<p><code>()<\/code>\uff1a\u5206\u7ec4&#8211;&gt;\u4f53\u73b0\u5728findall\u65b9\u6cd5\u4e0esearch\u3001macth\u65b9\u6cd5\u4e4b\u95f4\u7684\u533a\u522b<\/p>\n<h3>3.\u6b63\u5219\u89e3\u6790<\/h3>\n<blockquote>\n<p><strong>\u6848\u4f8b\u7f51\u5740<\/strong><\/p>\n<ol>\n<li><a href=\"https:\/\/www.imdb.com\/chart\/top\/?ref_=fn_nv_menu\">https:\/\/www.imdb.com\/chart\/top\/?ref_=fn_nv_menu<\/a><\/li>\n<li><a href=\"https:\/\/www.maoyan.com\/board\/4?timeStamp=1767789872419\">https:\/\/www.maoyan.com\/board\/4?timeStamp=1767789872419<\/a><\/li>\n<\/ol>\n<\/blockquote>\n<p><span style='color:black;font-size:20px;background:linear-gradient(to right, rgb(249, 168, 212), rgb(216, 180, 254), rgb(129, 140, 248));padding: 6px 8px;border-radius: 10px'><strong>\u6b63\u5219\u89e3\u6790\u7684\u4f18\u70b9\u5e76\u4e0d\u662f\u5728\u4e8e\u53ef\u4ee5\u5f88\u51c6\u786e\u7684\u83b7\u53d6\u6570\u636e\uff0c\u800c\u662f\u5b83\u53ef\u4ee5\u83b7\u53d6\u51fa\u4efb\u4f55\u4f60\u60f3\u8981\u83b7\u53d6\u7684\u6570\u636e<\/strong><\/span><\/p>\n<h4>\u6848\u4f8b\u4e00<\/h4>\n<p>\u83b7\u53d6\u7f51\u7ad9\u4e2d\u7684\u7535\u5f71\u540d\u3001\u7535\u5f71\u8bc4\u5206\uff0c\u7535\u5f71\u5e74\u4efd\u3001\u7535\u5f71\u65f6\u957f<\/p>\n<pre><code class=\"language-python\">import requests\nimport re\n\nurl = &#039;https:\/\/www.imdb.com\/chart\/top\/?ref_=fn_nv_menu&#039;\n\nheaders = {\n    &#039;cookie&#039;:&#039;session-id=133-9525601-0942401; session-id-time=2082787201l; ad-oo=0; ci=eyJhZ2VTaWduYWwiOiJBRFVMVCIsImlzR2RwciI6ZmFsc2V9; ubid-main=130-2984191-2615442; session-token=YoLKgL4H8W+ckpct8UwBW3dolcE+Px4dE12RAKFPsa5B+utgA4wzSF6Ghxw3hhSK9zh6ohd\/cb6MDEt+WYJKaP33GzQWKV8EcmnIcHkYnKxgZR\/zlmKTUUfhfR3slUt0u54gpSBLO548XnP\/rMJs46CQeS715Mgr9djGMSRQobrTWKdR5ts02pqU8o+FYgtgK8pRFvNrLtRq8WnEGo0ukFNgFzqhvu3YPsjpDeHT1vx+EkCv1Y5E4B4TsUcmL04M59aYMN0OWxlL+h0i+boAk0HlHw4ds+l2HbtK8U\/kSL15TdCQLTDRO8kBX3OdMolUmHa2Qhea6jnb+S1w0xa5LFD8wTVadNLm; csm-hit=tb:3587K4XC6086NRMSH4V8+s-BM1GD1E6FSAYGFZWCA95|1767778920598&amp;t:1767778920598&amp;adb:adblk_yes&#039;,\n    &#039;user-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&#039;,\n    &#039;referer&#039;:&#039;https:\/\/www.imdb.com\/find\/?q=top%2050%20movies&amp;ref_=chttp_nv_srb_sm&#039;\n}\n\n# \u65f6\u95f4\u8f6c\u6362\ndef time_conversion(second):\n    hour = second \/\/ 3600\n    minute = (second % 3600) \/\/ 60\n    return f&#039;{hour}h{minute}m&#039;\n\nres = requests.get(url,headers=headers)\n# \u7535\u5f71\u540d\nmovie_title = re.findall(r&#039;&quot;url&quot;:&quot;.*?&quot;,&quot;name&quot;:&quot;(.*?)&quot;,&quot;description&quot;&#039;, res.text)\n# \u7535\u5f71\u8bc4\u5206\nmovie_rating = re.findall(r&#039;&quot;worstRating&quot;:1,&quot;ratingValue&quot;:(.*?),&#039;, res.text)\n# \u7535\u5f71\u5e74\u4efd\nmovie_year = re.findall(r&#039;&quot;releaseYear&quot;:{&quot;year&quot;:(d{4}),&#039;, res.text)\n# \u7535\u5f71\u65f6\u957f\nmovie_duration = re.findall(r&#039;&quot;seconds&quot;:(d{4,5}),&#039;, res.text)\n# \u8f6c\u6362\u4e3axh xm \u683c\u5f0f\nmovie_duration_new = [time_conversion(int(i)) for i in movie_duration]\n\n# \u62fc\u63a5\u8f93\u51fa\nmax_len = min(len(movie_title), len(movie_rating), len(movie_year), len(movie_duration_new))\nfor i in range(max_len):\n    title = movie_title[i]\n    rating = movie_rating[i]\n    year = movie_year[i]\n    duration = movie_duration_new[i]\n    print(f&#039;\u7535\u5f71\u540d\u79f0\uff1a{title}&#039;)\n    print(f&#039;\u8bc4\u5206\uff1a{rating}&#039;)\n    print(f&#039;\u5e74\u4efd\uff1a{year}&#039;)\n    print(f&#039;\u65f6\u957f\uff1a{duration}&#039;)\n    print(&quot;*&quot;*80)\n<\/code><\/pre>\n<h4>\u6848\u4f8b\u4e8c<\/h4>\n<p>\u722c\u53d6\u732b\u773c\u7535\u5f71TOP100\u699c1-10\u9875\u7684\u6570\u636e<\/p>\n<pre><code class=\"language-python\">import requests\nimport re\n\nheaders = {\n    &#039;user-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&#039;,\n    &#039;referer&#039;:&#039;https:\/\/www.maoyan.com\/&#039;,\n    &#039;cookie&#039;:&#039;__mta=47143448.1767771051803.1767790754242.1767791308864.15; _lxsdk_cuid=19b975d6e6fc8-00450a48ddbee6-26061a51-1fa400-19b975d6e6fc8; uuid_n_v=v1; uuid=CA56C320EB9A11F09C6983D1745B13D9E85113618BC240D390361010F21FD821; _csrf=f3bcb09860b1c551112859ec8c32f4a92c56ca73d60be976066f96037dc10791; _lx_utm=utm_source%3DBaidu%26utm_medium%3Dorganic; _lxsdk=CA56C320EB9A11F09C6983D1745B13D9E85113618BC240D390361010F21FD821; _ga=GA1.1.1487119828.1767771051; __mta=47143448.1767771051803.1767771051803.1767791295955.2; _ga_WN80P4PSY7=GS2.1.s1767789851$o2$g1$t1767791308$j46$l0$h0; _lxsdk_s=19b987c7124-7a5-7d3-24e%7C%7C31&#039;,\n\n}\n\nresult = [i*10 for i in range(0,10)]\nfor i in result:\n    url = f&#039;https:\/\/www.maoyan.com\/board\/4?timeStamp=1767789872419&amp;offset={i}&#039;\n    res = requests.get(url,headers=headers)\n    # \u7535\u5f71\u540d\n    movie_title = re.findall(r&#039;data-val=&quot;{movieId:d{3,7}}&quot;&gt;(.*?)&lt;\/a&gt;&lt;\/p&gt;&#039;,res.text)\n    # \u4e3b\u6f14\n    starring = re.findall(r&#039;\u4e3b\u6f14\uff1a(.*?)s*&lt;\/p&gt;&#039;,res.text)\n    # \u4e0a\u6620\u65f6\u95f4\n    release_time = re.findall(r&#039;&lt;p class=&quot;releasetime&quot;&gt;\u4e0a\u6620\u65f6\u95f4\uff1a(.*?)&lt;\/p&gt;&#039;,res.text)\n    # \u8bc4\u5206\n    rating = re.findall(r&#039;&lt;p class=&quot;score&quot;&gt;&lt;i class=&quot;integer&quot;&gt;(d.)&lt;\/i&gt;&lt;i class=&quot;fraction&quot;&gt;(d)&lt;\/i&gt;&lt;\/p&gt;&#039;,res.text)\n    rating_new = [float(i[0]+i[1]) for i in rating]\n    # \u8f93\u51fa\n    max_len = min(len(movie_title),len(starring),len(release_time),len(rating_new))\n    for u in range(max_len):\n        title_date = movie_title[u]\n        starring_date = starring[u]\n        release_time_date = release_time[u]\n        rating_new_date = rating_new[u]\n        print(f&#039;\u7535\u5f71\u540d\uff1a{title_date}&#039;)\n        print(f&#039;\u4e3b\u6f14\uff1a{starring_date}&#039;)\n        print(f&#039;\u4e0a\u6620\u65f6\u95f4\uff1a{release_time_date}&#039;)\n        print(f&#039;\u8bc4\u5206\uff1a{rating_new_date}&#039;)\n        print(&#039;*&#039;*50)\n<\/code><\/pre>\n<h2>\u516d\u3001XPATH\u89e3\u6790<\/h2>\n<h3>1.XPATH\u7684\u4f7f\u7528<\/h3>\n<h4>XPATH\u7684\u5199\u6cd5<\/h4>\n<p>\u5982\u679c\u6ca1\u6709\u9650\u5b9a\u5177\u4f53\u6807\u7b7e\u65f6\uff0c\u4f1a\u627e\u5230\u540c\u7ea7\u7684\u6240\u6709\u5f53\u524d\u6807\u7b7e<\/p>\n<p><code><\/code>\uff1a\u8868\u793a\u5206\u7ea7<\/p>\n<ul>\n<li><code>htmlbody<\/code><\/li>\n<\/ul>\n<p><code>[n]<\/code>\uff1a\u4e0b\u6807\u9650\u5236\uff0c<code>n<\/code>\u4e3a\u6574\u6570\uff0c<font color='red'>\u6ce8\uff1a<\/font>XPATH\u4e2d\u4e0b\u6807\u4ece1\u5f00\u59cb<\/p>\n<ul>\n<li><code>html\/body\/div[7]<\/code><\/li>\n<\/ul>\n<p><code>\u5143\u7d20[@\u5c5e\u6027=&quot;\u5c5e\u6027\u503c&quot;]<\/code>\uff1a\u5c5e\u6027\u9650\u5236<\/p>\n<ul>\n<li><code>html\/body\/div[@class=&quot;pages&quot;]<\/code><\/li>\n<\/ul>\n<p><code>\/\/<\/code>\uff1a\u8868\u793a\u5f53\u524d\u8282\u70b9\u4e0b\u4efb\u610f\u5c42\u7ea7\u7684\u6807\u7b7e<\/p>\n<ul>\n<li><code>\/\/div[@class=&quot;pages&quot;]<\/code><\/li>\n<\/ul>\n<h3>2.\u63d0\u53d6\u6570\u636e<\/h3>\n<h4>text<\/h4>\n<p><code>text()<\/code>\uff1a\u63d0\u53d6\u6807\u7b7e\u5f53\u4e2d\u7684\u5185\u5bb9<\/p>\n<ul>\n<li><code>html\/body\/div[7]\/div[3]\/div[4]\/div[1]\/ul\/li[1]\/div[1]\/h2\/a\/text()<\/code><\/li>\n<\/ul>\n<h4>@\u5c5e\u6027<\/h4>\n<p><code>@\u5c5e\u6027<\/code>\uff1a\u83b7\u53d6\u6807\u7b7e\u4e2d\u7684\u5c5e\u6027\u503c<\/p>\n<ul>\n<li><code>html\/body\/div[7]\/div[3]\/div[4]\/div[1]\/ul\/li[1]\/div[1]\/h2\/a\/@href<\/code><\/li>\n<\/ul>\n<h3>\u5b9e\u6218\u4e00<\/h3>\n<p>\u4f7f\u7528XPATH\u83b7\u53d6<a href=\"https:\/\/www.maoyan.com\/board\/4?timeStamp=1767789872419&amp;offset=0\">\u732b\u773cTOP100\u699c<\/a>1-10\u9875\u7684\u6570\u636e<\/p>\n<pre><code class=\"language-python\">import requests\nfrom lxml import etree  # \u5bfc\u5165xpath\u65b9\u6cd5\n\nheaders = {\n    &#039;user-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&#039;,\n    &#039;referer&#039;:&#039;https:\/\/www.maoyan.com\/&#039;,\n    &#039;cookie&#039;:&#039;__mta=47143448.1767771051803.1767790754242.1767791308864.15; _lxsdk_cuid=19b975d6e6fc8-00450a48ddbee6-26061a51-1fa400-19b975d6e6fc8; uuid_n_v=v1; uuid=CA56C320EB9A11F09C6983D1745B13D9E85113618BC240D390361010F21FD821; _csrf=f3bcb09860b1c551112859ec8c32f4a92c56ca73d60be976066f96037dc10791; _lx_utm=utm_source%3DBaidu%26utm_medium%3Dorganic; _lxsdk=CA56C320EB9A11F09C6983D1745B13D9E85113618BC240D390361010F21FD821; _ga=GA1.1.1487119828.1767771051; __mta=47143448.1767771051803.1767771051803.1767791295955.2; _ga_WN80P4PSY7=GS2.1.s1767789851$o2$g1$t1767791308$j46$l0$h0; _lxsdk_s=19b987c7124-7a5-7d3-24e%7C%7C31&#039;,\n\n}\n\n# \u8bc4\u5206\u62fc\u63a5\ndef splice(a, b):\n    rating_list = []\n    max_len1 = min(len(a),len(b))\n    for i in range(max_len1):\n        a1 = a[i]\n        b1 = b[i]\n        rating_info = float(a1 + b1)\n        rating_list.append(rating_info)\n    return rating_list\n\nresult = [i*10 for i in range(0,10)]\nfor i in result:\n    url = f&#039;https:\/\/www.maoyan.com\/board\/4?timeStamp=1767789872419&amp;offset={i}&#039;\n    res = requests.get(url,headers=headers)\n    # res\n    # \u5c06text\u8f6c\u6362\u4e3ahtml\u9875\u9762\u4fe1\u606f\uff0c\u56e0\u4e3a\u83b7\u53d6\u7684\u6570\u636e\u662f\u5b57\u7b26\u4e32\u4fe1\u606f\uff0c\u5b57\u7b26\u4e32\u6570\u636e\u4e0d\u5177\u5907\u7f51\u9875\u7ed3\u6784\uff0c\u56e0\u6b64\u9700\u8981\u8f6c\u6362\u4e3ahtml\u9875\u9762\u7ed3\u6784\uff0c\u624d\u80fd\u4f7f\u7528XPATH\n    res_html = etree.HTML(res.text)\n    # \u7535\u5f71\u540d\n    movie_title = res_html.xpath(&#039;\/\/div[4]\/div\/div\/div[1]\/dl\/dd\/div\/div\/div[1]\/p\/a\/text()&#039;)\n    # \u4e3b\u6f14\n    starring = tuple(map(lambda x:x.strip(), res_html.xpath(&#039;\/\/div[4]\/div\/div\/div[1]\/dl\/dd\/div\/div\/div[1]\/p[2]\/text()&#039;)))\n    # \u4e0a\u6620\u65f6\u95f4\n    release_time = res_html.xpath(&#039;\/\/div[4]\/div\/div\/div[1]\/dl\/dd\/div\/div\/div[1]\/p[3]\/text()&#039;)\n    # \u8bc4\u5206\n    num1 = res_html.xpath(&#039;\/\/div[4]\/div\/div\/div[1]\/dl\/dd\/div\/div\/div[2]\/p\/i[1]\/text()&#039;)\n    num2 = res_html.xpath(&#039;\/\/div[4]\/div\/div\/div[1]\/dl\/dd\/div\/div\/div[2]\/p\/i[2]\/text()&#039;)\n    rating = splice(num1,num2)\n    # \u8f93\u51fa\u7ed3\u679c\n    max_len = min(len(movie_title),len(starring),len(release_time),len(rating))\n    for m in range(max_len):\n        movie_title_m = movie_title[m]\n        starring_m = starring[m]\n        release_time_m = release_time[m]\n        rating_m = rating[m]\n        print(f&#039;\u7535\u5f71\u540d\uff1a{movie_title_m}&#039;)\n        print(starring_m)\n        print(release_time_m)\n        print(rating_m)\n        print(&#039;*&#039;*80)\n<\/code><\/pre>\n<blockquote>\n<p>\u5982\u679c\u78b0\u5230\u6807\u7b7e\u6570\u636e\u5206\u6563\u7684\u60c5\u51b5\u4e0b\uff0c\u9700\u8981\u5c06\u6570\u636e\u7efc\u5408\u65f6\uff0c\u5e94\u5f53\u5148\u628a\u4ed6\u4eec\u6240\u5171\u6709\u7684\u90e8\u5206\u83b7\u53d6\u51fa\u6765\uff0c\u7136\u540e\u5bf9\u5176\u5355\u72ec\u7684\u83b7\u53d6\u6570\u636e<\/p>\n<\/blockquote>\n<h3>\u5b9e\u6218\u4e8c<\/h3>\n<p>\u83b7\u53d6<a href=\"https:\/\/www.xxsy.net\/rank\">\u6f47\u6e58\u4e66\u9662\u6392\u884c\u699c<\/a>\u6240\u6709\u4e66\u540d\u3001ID\u53ca\u4f5c\u8005<\/p>\n<pre><code class=\"language-python\">import requests\nfrom lxml import etree\n\nurl = &#039;https:\/\/www.xxsy.net\/rank&#039;\n\nheaders = {\n    &#039;user-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&#039;,\n    &#039;cookie&#039;:&#039;newstatisticUUID=1767077440_8196224563&#039;,\n    &#039;referer&#039;:&#039;https:\/\/www.xxsy.net\/&#039;\n}\n\nres = requests.get(url,headers=headers)\nres_html = etree.HTML(res.text)\n# \u4e66\u540d\nbooks_name = res_html.xpath(&#039;\/\/div[@id=&quot;app&quot;]\/div[4]\/div[2]\/div[2]\/div\/div[2]\/ul\/li\/p\/a\/text()&#039;)\n# \u56fe\u4e66ID\nbooks_id = res_html.xpath(&#039;\/\/div[@id=&quot;app&quot;]\/div[4]\/div[2]\/div[2]\/div\/div[2]\/ul\/li\/p\/a\/@href&#039;)\n# \u4f5c\u8005\nbooks_author = res_html.xpath(&#039;\/\/div[@id=&quot;app&quot;]\/div[4]\/div[2]\/div[2]\/div\/div[2]\/ul\/li\/span[1]\/text()&#039;)\n# \u62fc\u63a5\u7f51\u5740\nbooks_https = tuple(map(lambda x:&#039;https:\/\/www.xxsy.net&#039;+x,books_id))\n# \u8f93\u51fa\nbooks_list = [f&#039;\u4e66\u540d\uff1a{name}n\u4f5c\u8005\uff1a{author}n\u94fe\u63a5\uff1a{https}n{&#039;*&#039;*80}&#039; for name,author,https in zip(books_name,books_author,books_https)]\n\nfor book in books_list:\n    print(book)\n<\/code><\/pre>\n<h2>\u4e03\u3001HTML\u5f02\u5e38\u5904\u7406<\/h2>\n<h3>1.HTML\u5f02\u5e38<\/h3>\n<ol>\n<li>\u54cd\u5e94\u6570\u636e\u4e0e\u6d4f\u89c8\u5668\u5f53\u4e2d\u7684\u6570\u636e\u5b58\u5728\u5dee\u5f02<\/li>\n<li>1-100\u9875\uff0c\u5176\u4e2d23\u51fa\u73b0\u95ee\u9898\uff0c\u8fd9\u4e2a\u9875\u9762\u6ca1\u6709\u4e86<\/li>\n<\/ol>\n<h4>\u5b9e\u6218\u4e00<\/h4>\n<p>\u722c\u53d6<a href=\"https:\/\/newhouse.fang.com\/house\/s\/b91\/\">\u623f\u5929\u4e0b\u65b0\u623f1-10\u9875<\/a>\u4e2d\u7684\u6570\u636e<\/p>\n<pre><code class=\"language-python\">import requests\nfrom lxml import etree\n\n# \u6e05\u9664\u51fd\u6570\ndef clear_string(z, s_list):\n    s = f&#039;{z}&#039;.join(s_list).strip().replace(&#039; &#039;, &#039;&#039;)\n    return s\n\n# \u88c5\u9970\u5668\uff0c\u9632\u6b62\u7f51\u9875\u65e0\u6cd5\u52a0\u8f7d\u65f6\u62a5\u9519\u7ed3\u675f\u8fdb\u7a0b\ndef requests_error(func):\n    def requests_error_except(url):\n        try:\n            res = requests.get(url=url, headers=headers)\n        except Exception as e:\n            print(f&#039;{url}----&gt;{e}&#039;)\n        else:\n            func(res)\n    return requests_error_except\n\n@requests_error\ndef res_try(res):\n    res_html = etree.HTML(res.text)\n    elements_li = res_html.xpath(&#039;\/\/div[@id=&quot;bx1&quot;]\/div\/div[1]\/div\/div\/div\/ul\/li&#039;)\n    # \u65b0\u623f\u540d\n    house_name = tuple(map(lambda x: clear_string(&#039;&#039;, x.xpath(&#039;.\/\/div[@class=&quot;nlcd_name&quot;]\/a\/text()&#039;)), elements_li))\n    # \u6237\u578b\n    house_type = tuple(map(lambda x: clear_string(&#039;&#039;, x.xpath(&#039;.\/\/div[@class=&quot;house_type clearfix&quot;]\/\/text()&#039;)), elements_li))\n    # \u5730\u5740\n    address = tuple(map(lambda x: clear_string(&#039;&#039;, x.xpath(&#039;.\/\/div[@class=&quot;address&quot;]\/\/@title&#039;)), elements_li))\n    # \u6807\u7b7e\n    fangyuan = tuple(map(lambda x: clear_string(&#039;\/&#039;, x.xpath(&#039;.\/\/div[@class=&quot;fangyuan&quot;]\/\/text()&#039;)), elements_li))\n    # \u4ef7\u683c\n    house_price = tuple(map(lambda x: clear_string(&#039;\/&#039;, x.xpath(&#039;.\/div[1]\/div[2]\/div[5]\/\/text()&#039;)), elements_li))\n    # \u7535\u8bdd\n    house_phone = tuple(map(lambda x: clear_string(&#039;&#039;, x.xpath(&#039;.\/\/div[@class=&quot;tel&quot;]\/p\/\/text()&#039;)), elements_li))\n\n    house_list = []\n\n    max_len = min(len(house_name),len(house_type),len(address),len(fangyuan),len(house_price),len(house_phone))\n\n    for u in range(max_len):\n        a = house_name[u]\n        b = house_type[u]\n        c = address[u]\n        d = fangyuan[u]\n        e = house_price[u]\n        f = house_phone[u]\n        house_list.append(f&#039;\u5c0f\u533a\u540d\uff1a{a}\uff0c\u6237\u578b\uff1a{b}\uff0c\u5730\u5740\uff1a{c}\uff0c\u6807\u7b7e\uff1a{d}\uff0c\u4ef7\u683c\uff1a{e}\uff0c\u7535\u8bdd\uff1a{f}&#039;)\n\n    for li in house_list:\n        with open(&#039;book\/houses.txt&#039;, &#039;a&#039;, encoding=&#039;utf-8&#039;) as f:\n            f.write(f&#039;{li}n&#039;)\n\n\nif __name__ == &#039;__main__&#039;:\n    for i in range(1, 11):\n        url = f&#039;https:\/\/newhouse.fang.com\/house\/s\/b9{i}\/&#039;\n        headers = {\n            &#039;user-agent&#039;: &#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&#039;,\n            &#039;cookie&#039;: &#039;global_cookie=zawiyz5btr1jlt6qzqud4vuzm10mk270vgn; city=www1; otherid=accb6736de6a81dacfbdaf6477400308; csrfToken=exWSPIZB1k-XXrJ7s1mDAWgF; unique_cookie=U_6ixbd5vz73mipuw3li39h244m2omk88nvgd*9&#039;,\n        }\n        if i == 4:\n            url = f&#039;https:\/\/www.google.com\/&#039;\n        house = res_try(url)\n<\/code><\/pre>\n<h4>\u5b9e\u6218\u4e8c<\/h4>\n<p>\u722c\u53d6<a href=\"http:\/\/www.ifang.com\/newHouse\/list\">\u4e00\u623f\u7f51-\u9752\u5c9b\u65b0\u623f<\/a>\u7684\u6570\u636e<\/p>\n<pre><code class=\"language-python\">import requests\nfrom lxml import etree\nfrom tqdm import trange     # \u8fdb\u5ea6\u6761\n\n# \u6e05\u9664\u51fd\u6570\ndef clear_string(z, s_list):\n    s = f&#039;{z}&#039;.join(s_list).strip().replace(&#039; &#039;, &#039;&#039;)\n    return s\n\n\n# \u88c5\u9970\u5668\uff0c\u9632\u6b62\u7f51\u9875\u65e0\u6cd5\u52a0\u8f7d\u65f6\u62a5\u9519\u7ed3\u675f\u8fdb\u7a0b\ndef requests_error(func):\n    def requests_error_except(url):\n        try:\n            res = requests.get(url=url, headers=headers)\n        except Exception as e:\n            print(f&#039;{url}----&gt;{e}&#039;)\n        else:\n            func(res)\n\n    return requests_error_except\n\n\n@requests_error\ndef res_try(res):\n    res_html = etree.HTML(res.text)\n    elements_li = res_html.xpath(&#039;\/\/div[@class=&quot;property-item-box&quot;]&#039;)\n    # \u65b0\u623f\u540d\n    house_name = tuple(map(lambda x: clear_string(&#039;&#039;, x.xpath(&#039;.\/\/p[@class=&quot;property-item-title&quot;]\/span[1]\/text()&#039;)), elements_li))\n    # \u6237\u578b\n    house_type = tuple(map(lambda x: clear_string(&#039;&#039;, x.xpath(&#039;.\/\/p[3]\/\/text()&#039;)), elements_li))\n    # \u5730\u5740\n    address = tuple(map(lambda x: clear_string(&#039;&#039;, x.xpath(&#039;.\/\/div[@class=&quot;property-item-main&quot;]\/p[2]\/\/text()&#039;)), elements_li))\n    # \u623f\u6e90\n    fangyuan = tuple(map(lambda x: clear_string(&#039;\/&#039;, x.xpath(&#039;.\/\/p[@class=&quot;property-item-title&quot;]\/span[@class=&quot;el-tag el-tag--mini el-tag--dark&quot;]\/text()&#039;)), elements_li))\n    # \u4ef7\u683c\n    house_price = tuple(map(lambda x: clear_string(&#039;\/&#039;, x.xpath(&#039;.\/\/div[@class=&quot;price-info&quot;]\/span\/text()&#039;)), elements_li))\n    # \u6807\u7b7e\n    house_label = tuple(map(lambda x: clear_string(&#039;\/&#039;, x.xpath(&#039;.\/\/div[@class=&quot;property-item-bottom&quot;]\/\/text()&#039;)), elements_li))\n\n    house_list = []\n\n    max_len = min(len(house_name), len(house_type), len(address), len(fangyuan), len(house_price), len(house_label))\n\n    for u in range(max_len):\n        a = house_name[u]\n        b = house_type[u]\n        c = address[u]\n        d = fangyuan[u]\n        e = house_price[u]\n        f = house_label[u]\n        house_list.append(f&#039;\u5c0f\u533a\u540d\uff1a{a}\uff0c\u6237\u578b\uff1a{b}\uff0c\u5730\u5740\uff1a{c}\uff0c\u623f\u6e90\uff1a{d}\uff0c\u4ef7\u683c\uff1a{e}\uff0c\u6807\u7b7e\uff1a{f}&#039;)\n\n    for li in house_list:\n        with open(&#039;book\/qingdao_houses.txt&#039;, &#039;a&#039;, encoding=&#039;utf-8&#039;) as f:\n            f.write(f&#039;{li}n&#039;)\n\n\nif __name__ == &#039;__main__&#039;:\n    for i in trange(1, 11):\n        url = f&#039;http:\/\/www.ifang.com\/newHouse\/list\/&amp;\/pg{i}\/&#039;\n        headers = {\n            &#039;user-agent&#039;: &#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&#039;,\n        }\n        res_try(url)\n<\/code><\/pre>\n<h2>\u516b\u3001SQL\u6570\u636e\u5e93\u64cd\u4f5c<\/h2>\n<h3>1.mysql\u914d\u7f6e<\/h3>\n<p>\u6253\u5f00\u914d\u7f6e\u6587\u4ef6<\/p>\n<pre><code class=\"language-shell\">vim \/etc\/mysql\/mysql.conf.d\/mysqld.cnf\n<\/code><\/pre>\n<p>\u5c06\u914d\u7f6e\u6587\u4ef6\u4e2d\u7684**<code>bind-address<\/code>**\u8bbe\u7f6e\u4e3a<code>0.0.0.0<\/code><\/p>\n<p><font color='red'><strong>\u6ce8\uff1a<\/strong><\/font>\u4fee\u6539\u914d\u7f6e\u6587\u4ef6\uff0c\u9700\u8981\u6682\u505cmysql\u670d\u52a1<\/p>\n<pre><code class=\"language-shell\">service mysql stop\t# \u6682\u505cmysql\u670d\u52a1\nservice mysql start\t# \u5f00\u542fmysql\u670d\u52a1\n<\/code><\/pre>\n<h3>2.\u6d4b\u8bd5\u8fde\u63a5\u6570\u636e\u5e93<\/h3>\n<p>\u672c\u5730\u4e0b\u8f7d**<code>pymsql<\/code>**\u6a21\u5757<\/p>\n<pre><code class=\"language-shell\">pip install pymysql\n<\/code><\/pre>\n<h4>\u6d4b\u8bd5\u8fde\u63a5<\/h4>\n<pre><code class=\"language-python\">from pymysql import Connect\n\nmysql = Connect(\n    host = &quot;localhost&quot;,\n    # host = &quot;127.0.0.1&quot;,\n    port = 3306,\n    user = &quot;root&quot;,\n    password = &quot;huihuia24&quot;,\n    charset = &quot;utf8&quot;\n)\nmsyql\t# \u65ad\u70b9\n<\/code><\/pre>\n<h3>\u5b9e\u6218\u4e00<\/h3>\n<p>\u722c\u53d6<a href=\"https:\/\/www.mafengwo.cn\/localdeals\/\/\">\u9a6c\u8702\u7a9d-\u53bb\u65c5\u884c-\u6b63\u5728\u70ed\u5356<\/a>\u4e2d\u7684\u6570\u636e\uff0c\u5e76\u5b58\u5165\u6570\u636e\u5e93<\/p>\n<pre><code class=\"language-python\">from pymysql import Connect\nimport requests\nfrom lxml import etree\n\nurl = &#039;https:\/\/www.mafengwo.cn\/localdeals\/\/&#039;\nheaders = {\n    &#039;cookie&#039;:&#039;mfw_uuid=69674779-4986-8e88-cbe4-c30ff333c37d; oad_n=a%3A3%3A%7Bs%3A3%3A%22oid%22%3Bi%3A1029%3Bs%3A2%3A%22dm%22%3Bs%3A15%3A%22www.mafengwo.cn%22%3Bs%3A2%3A%22ft%22%3Bs%3A19%3A%222026-01-14+15%3A36%3A25%22%3B%7D; __mfwc=direct; __mfwa=1768376185854.89689.1.1768376185854.1768376185854; __mfwlv=1768376185; __mfwvn=1; uva=s%3A92%3A%22a%3A3%3A%7Bs%3A2%3A%22lt%22%3Bi%3A1768376186%3Bs%3A10%3A%22last_refer%22%3Bs%3A24%3A%22https%3A%2F%2Fwww.mafengwo.cn%2F%22%3Bs%3A5%3A%22rhost%22%3BN%3B%7D%22%3B; __mfwurd=a%3A3%3A%7Bs%3A6%3A%22f_time%22%3Bi%3A1768376186%3Bs%3A9%3A%22f_rdomain%22%3Bs%3A15%3A%22www.mafengwo.cn%22%3Bs%3A6%3A%22f_host%22%3Bs%3A3%3A%22www%22%3B%7D; __mfwuuid=69674779-4986-8e88-cbe4-c30ff333c37d; bottom_ad_status=0; PHPSESSID=ohha4pifncjblkb81uq9ai9i73; __omc_chl=; __omc_r=; __mfwb=76ff3f541d7e.9.direct; __mfwlt=1768377937; w_tsfp=ltvuV0MF2utBvS0Q76Lqk0ynETsjdD84h0wpEaR0f5thQLErU5mD2YV9ucLwNHTY5sxnvd7DsZoyJTLYCJI3dwMSRMmQd9wX31uQxoIjjYdAAhMxEZ7dWlMbJL8kuDRHe3hCNxS00jA8eIUd379yilkMsyN1zap3TO14fstJ019E6KDQmI5uDW3HlFWQRzaLbjcMcuqPr6g18L5a5T\/Z5Qiufw18BLlK1UObgXtLW3Er4BLqIuBZMh\/\/I53+SqA=&#039;,\n    &#039;user-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&#039;,\n}\nres = requests.get(url, headers=headers)\nres_html = etree.HTML(res.text)\n# \u83b7\u53d6\u6240\u6709\u7684li\u6807\u7b7e\nall_li = res_html.xpath(&#039;\/\/div[@class=&quot;bd hotSales&quot;]\/ul\/li&#039;)\n# \u5173\u95ed\u8fde\u63a5\nres.close()\n# \u7c7b\u578b\nmark_tag = tuple(map(lambda x:(x.xpath(&#039;.\/\/div[@class=&quot;mark-tag&quot;]\/text()&#039;) or [&#039;\u6682\u65e0&#039;])[0], all_li))\n# \u4fe1\u606f\nres_information = tuple(map(lambda x:(x.xpath(&#039;.\/\/div[@class=&quot;caption&quot;]\/h3\/text()&#039;) or [&#039;\u6682\u65e0&#039;])[0], all_li))\n# \u51fa\u552e\u60c5\u51b5\nsell = tuple(map(lambda x:(x.xpath(&#039;.\/\/div[@class=&quot;caption&quot;]\/span[1]\/text()&#039;) or [&#039;\u6682\u65e0&#039;])[0].split(&#039;|&#039;), all_li))\n# \u5e97\u94fa\nsold = tuple(map(lambda x:x.pop(),sell))\nsell2 = tuple(map(lambda x:x[0].replace(&#039; &#039;,&#039;&#039;) if x else &#039;\u6682\u65e0&#039;, sell))\n# \u4ef7\u683c\nprice = tuple(map(lambda x: &#039;\uffe50\u8d77&#039; if (s:=&#039;&#039;.join(x.xpath(&#039;.\/\/div[@class=&quot;caption&quot;]\/span[2]\/\/text()&#039;)).replace(&#039; &#039;,&#039;&#039;)) == &#039;\uffe5\u8d77&#039; else s, all_li))\n\n# \u5c06\u6570\u636e\u4fdd\u5b58\u81f3\u6570\u636e\u5e93\n# \u8fde\u63a5\u6570\u636e\u5e93\nmysql = Connect(\n    host = &quot;localhost&quot;,\n    # host = &quot;127.0.0.1&quot;,\n    port = 3306,\n    user = &quot;root&quot;,\n    password = &quot;huihuia24&quot;,\n    charset = &quot;utf8mb4&quot;\n)\n# \u5f00\u542f\u6e38\u6807\ncursor = mysql.cursor()\n# \u521b\u5efa\u6570\u636e\u5e93(\u5982\u679c\u6570\u636e\u5e93\u5b58\u5728\u5c31\u4e0d\u4f1a\u521b\u5efa)\ncursor.execute(&#039;create database if not exists mafengwo;&#039;)\n# \u8fdb\u5165\u6570\u636e\u5e93\ncursor.execute(&#039;use mafengwo;&#039;)\n# \u5efa\u8868\ncursor.execute(&#039;create table if not exists localdeals(&#039;\n               &#039;id int primary key auto_increment,&#039;\n               &#039;mark_tag varchar(255) not null,&#039;\n               &#039;res_information varchar(255) not null,&#039;\n               &#039;sell char(30) not null,&#039;\n               &#039;sold char(30) not null,&#039;\n               &#039;price char(20) not null);&#039;)\n# \u63d2\u5165\u6570\u636e\ninsert_sql = &#039;insert into localdeals(mark_tag,res_information,sell,sold,price) values (%s,%s,%s,%s,%s);&#039;\n&quot;&quot;&quot;\u5355\u6761\u6570\u636e\u63d2\u5165&quot;&quot;&quot;\n# cursor.execute(insert_sql, (\u6570\u636e))\n&quot;&quot;&quot;\n\u591a\u6761\u63d2\u5165\ncursor.executemany(insert_sql, data)\n\u591a\u6761\u63d2\u5165\u65f6date\u7684\u6570\u636e\u683c\u5f0f\ndata = (\n(mark_tag1,information1,sell1,sold1,price1),\n(mark_tag2,information2,sell2,sold2,price2),\n(mark_tag3,information3,sell3,sold3,price3)\n)\n&quot;&quot;&quot;\ndata = tuple(map(lambda x:(x[1],res_information[x[0]],sell2[x[0]],sold[x[0]],price[x[0]]),enumerate(mark_tag)))\ncursor.executemany(insert_sql, data)\n# \u63d0\u4ea4\u4e8b\u52a1\nmysql.commit()\n# \u5173\u95ed\u6e38\u6807\ncursor.close()\n# \u5173\u95ed\u6570\u636e\u5e93\u8fde\u63a5\nmysql.close()\n<\/code><\/pre>\n<h3>\u5b9e\u6218\u4e8c<\/h3>\n<p>\u83b7\u53d6<a href=\"https:\/\/gratisography.com\/\">gratisography\u7f51<\/a>\u4e2d\u7684\u56fe\u7247\u94fe\u63a5\uff0c\u5e76\u4fdd\u5b58\u81f3\u6570\u636e\u5e93<\/p>\n<pre><code class=\"language-python\">import requests\nfrom pymysql import Connect\nfrom lxml import etree\nfrom tqdm import trange\n\nheaders = {\n    &#039;cookie&#039;: &#039;_ga=GA1.1.828024986.1768446989; _hjSession_2556496=eyJpZCI6IjJiYTdkNDU4LTQwNTEtNGRhOC1hNDE0LWUyMWRlZjQ1MGNiMCIsImMiOjE3Njg0NDY5OTA5NjEsInMiOjAsInIiOjAsInNiIjowLCJzciI6MCwic2UiOjAsImZzIjoxLCJzcCI6MX0=; _hjSessionUser_2556496=eyJpZCI6ImQ1N2VlYjVmLWRhM2QtNTZmZC04MWIxLTA3MTM3OGVjODUyNyIsImNyZWF0ZWQiOjE3Njg0NDY5OTA5NjAsImV4aXN0aW5nIjp0cnVlfQ==; _ga_TNFKZTM4P0=GS2.1.s1768446989$o1$g1$t1768447380$j52$l0$h0&#039;,\n    &#039;user-agent&#039;: &#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&#039;,\n}\nmysql = Connect(\n            host=&#039;localhost&#039;,\n            port=3306,\n            user=&#039;root&#039;,\n            password=&#039;huihuia24&#039;,\n            charset=&#039;utf8&#039;\n        )\n# \u5f00\u542f\u6e38\u6807\ncou = mysql.cursor()\n# \u521b\u5efa\u6570\u636e\u5e93\ncou.execute(&#039;create database if not exists gratisography;&#039;)\n# \u8fdb\u5165\u6570\u636e\u5e93\ncou.execute(&#039;use gratisography&#039;)\n# \u521b\u5efa\u8868\ncou.execute(&#039;create table if not exists img_url(&#039;\n            &#039;id int primary key auto_increment,&#039;\n            &#039;name varchar(500) not null,&#039;\n            &#039;data longblob not null);&#039;)\nfor i in trange(1, 11):\n    url = f&#039;https:\/\/gratisography.com\/page\/{i}\/?s=girl&#039;\n    res = requests.get(url, headers=headers)\n    res_html = etree.HTML(res.text)\n    # \u56fe\u7247\u5730\u5740\n    img_type = res_html.xpath(&#039;\/\/div[@class=&quot;off-canvas-content&quot;]\/section[2]\/div\/div\/article\/div\/a[1]\/img\/@src&#039;)\n    img_info = tuple(map(lambda x: x.replace(&#039;-800x525&#039;, &#039;&#039;), img_type))\n    res.close()\n    # \u5c06\u56fe\u7247\u5730\u5740\u8fdb\u884c\u8bf7\u6c42\n    for a in range(len(img_info)):\n        img_url_b = requests.get(url= img_info[a], headers=headers)\n        img_s = img_url_b.content\n        img_url_b.close()\n        # with open(f&#039;girl\/{img_info[a]}&#039;, &#039;wb&#039;, ) as f:\n        #     f.write(img_s)\n        # \u63d2\u5165\u6570\u636e\n        sql = &#039;insert into img_url(name,data) values(%s,%s);&#039;\n        cou.execute(sql, (img_info[a], img_s))\n        # \u63d0\u4ea4\n        mysql.commit()\n# \u5173\u95ed\ncou.close()\nmysql.close()\n<\/code><\/pre>\n<h3>\u5b9e\u6218\u4e09<\/h3>\n<p>\u83b7\u53d6<a href=\"https:\/\/travelsearch.fliggy.com\/index.htm?spm=181.15077045.1398723350.1.53e1620diuwEiI&amp;searchType=product&amp;keyword=%E4%B8%BD%E6%B1%9F&amp;category=MULTI_SEARCH\">\u98de\u732a\u65c5\u884c-\u65c5\u6e38\u5ea6\u5047-\u4e3d\u6c5f<\/a>\u4e2d1-3\u9875\u6570\u636e,\u5e76\u50a8\u5b58\u81f3\u6570\u636e\u5e93\u4e2d<\/p>\n<pre><code class=\"language-python\">import requests\nfrom lxml import etree\nfrom pymysql import Connect\n\n\n\n# \u56fe\u7247URL\u5904\u7406\ndef img_url_info(u):\n    img_data_list = []\n    for l in u:\n        res_img = requests.get(l,headers=headers)\n        res_b = res_img.content\n        img_data_list.append(res_b)\n        res_img.close()\n    img_data_tuple = tuple(img_data_list)\n    return img_data_tuple\n\n# \u94fe\u63a5\u6570\u636e\u5e93\nmysql = Connect(\n    host = &#039;localhost&#039;,\n    port = 3306,\n    user = &#039;root&#039;,\n    passwd = &#039;huihuia24&#039;,\n    charset = &#039;utf8&#039;\n)\n# \u5f00\u542f\u6e38\u6807\ncur = mysql.cursor()\n# \u521b\u5efa\u6570\u636e\u5e93\ncur.execute(&#039;create database if not exists pachong;&#039;)\n# \u8fdb\u5165\u6570\u636e\u5e93\ncur.execute(&#039;use pachong;&#039;)\n# \u5efa\u8868\ncur.execute(&#039;create table if not exists fliggy(&#039;\n            &#039;id int primary key auto_increment,&#039;\n            &#039;tag varchar(50) not null,&#039;\n            &#039;img_info longblob not null,&#039;\n            &#039;title varchar(500) not null,&#039;\n            &#039;address varchar(500) not null,&#039;\n            &#039;hotel_star varchar(50) not null,&#039;\n            &#039;rating decimal(3,1) not null,&#039;\n            &#039;price varchar(50) not null);&#039;)\n\n# \u722c\u53d6\u6570\u636e\nheaders = {\n    &#039;cookie&#039;:&#039;lid=tb764317057; wk_cookie2=19e5a18fda9e5ad850c05da184c6a41e; wk_unb=UUpgRsNstd9bfuqdKg%3D%3D; cna=1OHjIeP5NmUCAdyoNOTl3rxr; dnk=tb764317057; tracknick=tb764317057; havana_lgc_exp=1799134684908; lgc=; cookie2=1c38e67d82ce54a5b965cd32b31e8eb9; sgcookie=E100d%2BrbIrsZOUIv433Te5daGExY56POchz1s%2FktWzPR9ovYrr%2BVeaP%2FkTv6%2FHhSMt2tb2kBy1Qx0vApJIO%2BTaoC8orxzKpy3fKwfQaarj6NtrZNs6hLto83RMTAI9wzlYoE; cancelledSubSites=empty; t=67bfa247584aa29997f00573aeb0c26c; csg=a83283aa; sn=; _tb_token_=77633e36e6bd6; mtop_partitioned_detect=1; _m_h5_tk=12dba58ee68d6291653b5a96272cd2b2_1768740632889; _m_h5_tk_enc=4eaa6e69520b33d1dbd2ab5fdd64c4c9; xlly_s=1; isg=BAIC-EEM37FXjcNtw0Ec6_2AUwhk0wbtvQOkFEwbLnUgn6IZNGNW_YjMSZvjz36F; _mw_us_time_=1768734760944; x5sec=7b22733b32223a2263323331323134363939333636323639222c22617365727665723b33223a22307c434b654473387347454c61322f706345476738794d6a45774e7a51784f544d324d7a67794f7a45777a4e4c7132762f2f2f2f2f2f41513d3d227d; tfstk=gA4ZU9T8mNQZMj6ua70V8YLdA2utlqW7srMjiSVm1ADihmg2m8wH5lstcxRqL8gb1Pa1oky0pcMgfSG2u5HQhEN_ukL4wSU16q1tW53xoT65PrPT6qF1HwPNdWfmMqlgyPzlp53xo9OBog_z6RwhZfnio6ungb-ioxcM-6loNqYimFxHKvhmoqmimeAnZjJMoEccTWDKiqD0nqfE-vhmox2mobPusSYENcfdICT2ngHjbYViLUPL8fmMX5DeoE4UYckkIv8Doylai5b9qUSjEuHsVYehRFu4tjyEVlWy7-P0womUudf_ES2T8V3Pc1nzxkZSbkWMuvasg00mYIY0TqqimrulrplLx5Z0WRR2ofU_Pmk-YsYxc24Squ2wM_FnSj2x2r6JWAV0wzESzNJ-_kVr8g-6HX0gLrEwnnoi9Xk5T6-SezG1aeiJ5nKxx4hEF1G6Dnni9Xk5T6-vDD0-TY1s1&#039;,\n    &#039;user-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&#039;,\n    &#039;accept&#039;:&#039;text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/avif,image\/webp,image\/apng,*\/*;q=0.8,application\/signed-exchange;v=b3;q=0.7&#039;,\n    &#039;referer&#039;:&#039;https:\/\/www.fliggy.com\/&#039;\n}\nfor i in range(1,4):\n    if i == 1:\n        url = &#039;https:\/\/travelsearch.fliggy.com\/index.htm?spm=181.15077045.1398723350.13.7ab1620dOHgDhv&amp;searchType=product&amp;keyword=%E4%B8%BD%E6%B1%9F&amp;category=MULTI_SEARCH&#039;\n    else:\n        url = f&#039;https:\/\/travelsearch.fliggy.com\/index.htm?spm=181.15077045.1398723350.13.7ab1620dOHgDhv&amp;searchType=product&amp;keyword=%E4%B8%BD%E6%B1%9F&amp;category=MULTI_SEARCH&amp;pagenum={i}&#039;\n    res_z = requests.get(url, headers=headers)\n    res_z_html = etree.HTML(res_z.text)\n    # \u5168\u90e8div\n    div_all = res_z_html.xpath(&#039;\/\/div[@class=&quot;page-products-block-left clear-fix&quot;]\/div[1]\/div\/div&#039;)\n    # \u6807\u7b7e\n    tag = tuple(map(lambda x: x.xpath(&#039;.\/div[1]\/a\/span[1]\/text()&#039;)[0], div_all))\n    # \u56fe\u7247\u5730\u5740\n    img_url = tuple(map(lambda x: (&#039;https:&#039; + x.xpath(&#039;.\/div[1]\/a\/div\/img\/@data-src&#039;)[0].replace(&#039;_200x200xz&#039;,&#039;&#039;)).replace(&#039;https:https:\/\/&#039;,&#039;https:\/\/&#039;), div_all))\n    # \u56fe\u7247\u4e8c\u8fdb\u5236\u5143\u7ec4\n    img_info = img_url_info(img_url)\n    # \u6807\u9898\n    title = tuple(map(lambda x:x.xpath(&#039;.\/div[2]\/div[1]\/a\/h3\/div\/text()&#039;)[0], div_all))\n    # \u5730\u5740\n    address = tuple(map(lambda x:(x.xpath(&#039;.\/div[2]\/div[1]\/h4\/text()&#039;) or [&#039;\u672a\u77e5&#039;])[0].replace(&#039; | &#039;,&#039;&#039;), div_all))\n    # \u9152\u5e97\u661f\u7ea7\n    hotel_star = tuple(map(lambda x:(x.xpath(&#039;.\/div[2]\/p[1]\/\/text()&#039;) or [&#039;\u672a\u77e5&#039;])[0], div_all))\n    # \u8bc4\u5206\n    rating = tuple(map(lambda x:(x.xpath(&#039;.\/div[2]\/p[3]\/\/text()&#039;) or [&#039;0.0&#039;])[0], div_all))\n    # \u4ef7\u683c\n    price = tuple(map(lambda x:&#039;&#039;.join(x.xpath(&#039;.\/div[3]\/div\/div\/span\/\/text()&#039;) or [&#039;\u672a\u77e5&#039;]), div_all))\n    # \u5173\u95ed\n    res_z.close()\n    # \u6570\u636e\u62fc\u63a5\n    data = tuple(map(lambda x:(x[1],img_info[x[0]],title[x[0]],address[x[0]],hotel_star[x[0]],rating[x[0]],price[x[0]]),enumerate(tag)))\n    # \u5c06\u6570\u636e\u4f20\u5165\u6570\u636e\u5e93\u4e2d\n    sql = &#039;insert into fliggy(tag, img_info, title, address, hotel_star, rating, price) values (%s,%s,%s,%s,%s,%s,%s)&#039;\n    cur.executemany(sql,data)\n    # \u63d0\u4ea4\n    mysql.commit()\n# \u5173\u95ed\ncur.close()\nmysql.close()\n<\/code><\/pre>\n<h3>3.\u62d3\u5c55<\/h3>\n<h4>\u7f51\u7edc\u7f16\u7801\u8f6c\u6362<\/h4>\n<pre><code class=\"language-python\">from urllib import parse\n# \u5bfc\u5165urllib\ns = &#039;\u9999\u6e2f&#039;\nprint(parse.quote(s))\n# %E9%A6%99%E6%B8%AF\n<\/code><\/pre>\n<h2>\u4e5d\u3001\u591a\u7ebf\u7a0b-\u5f02\u6b65\u722c\u866b<\/h2>\n<blockquote>\n<p>\u5b9e\u73b0\u6279\u91cf\u722c\u866b\uff0c\u591a\u722c\u866b\u7edf\u4e00\u8fd0\u884c<\/p>\n<\/blockquote>\n<h3>1.\u591a\u7ebf\u7a0b<\/h3>\n<p>\u591a\u7ebf\u7a0b\u7684\u672c\u8d28\u5c31\u662f\u591a\u4e2a\u201c\u4eba\u201d\u4e00\u8d77\u722c\u53d6\u5185\u5bb9<\/p>\n<p>\u591a\u7ebf\u7a0b\u591a\u7528\u4e8eIO(\u8bfb\u5199)\u7684\u64cd\u4f5c(\u6587\u4ef6\u6253\u5f00\uff0c\u6570\u636e\u5b58\u50a8\uff0c\u722c\u866b\u7b49\u5f85)<\/p>\n<h4>\u591a\u7ebf\u7a0b\u7684\u4f7f\u7528<\/h4>\n<p>\u4e0d\u4f7f\u7528\u591a\u7ebf\u7a0b<\/p>\n<pre><code class=\"language-python\">import time\n\nstart = time.time()\n\ndef sleep_time(x):\n    print(x)\n    time.sleep(2)\n\nfor i in range(1,11):\n    sleep_time(i)\n\nprint(time.time() - start)\n# \u8fd0\u884c\u65f6\u95f420\u79d2\n<\/code><\/pre>\n<p>\u4f7f\u7528\u591a\u7ebf\u7a0b<\/p>\n<pre><code class=\"language-python\">import time\nfrom threading import Thread    # \u7ebf\u7a0b\u6a21\u5757\n\nstart = time.time()\n\ndef sleep_time(x):\n    print(x)\n    time.sleep(2)\n\ntasks = [Thread(target=sleep_time,args=(i,))for i in range(1,11)]\nfor t in tasks:\n    # \u542f\u52a8\u7ebf\u7a0b\u4efb\u52a1\n    t.start()\nfor x in tasks:\n    # \u5b88\u62a4\u7ebf\u7a0b\n    x.join()\n\nprint(time.time() - start)\n# \u8fd0\u884c\u65f6\u95f42\u79d2\n<\/code><\/pre>\n<h4>\u5b9e\u6218<\/h4>\n<p>\u4f7f\u7528\u591a\u7ebf\u7a0b\u5bf9<a href=\"https:\/\/b.faloo.com\/\">\u98de\u5362\u5c0f\u8bf4\u7f51<\/a>\u4e2d\u7684\u63a8\u7406\u7075\u5f02\u5185\u7684\u4e66\u7c4d\u5185\u5bb9\u8fdb\u884c\u722c\u53d6<\/p>\n<pre><code class=\"language-python\">import requests\nimport re\nfrom lxml import etree\nfrom threading import Thread\n\ndef book_id():\n    book_id_url = &#039;https:\/\/b.faloo.com\/&#039;\n    headers ={\n        &#039;user-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&#039;,\n\n    }\n    book_id_res = requests.get(url=book_id_url, headers=headers)\n    book_id_html = etree.HTML(book_id_res.text)\n    books_id = tuple(map(lambda x: re.findall(r&#039;\/\/b.faloo.com\/(d+).html?1&#039;, x)[0],book_id_html.xpath(&#039;\/\/div[@class=&quot;TenLeft&quot;]\/div[2]\/div[1]\/div[2]\/ul\/li\/div\/a\/@href&#039;)))\n    return books_id\n\ndef book_count(id_info):\n    f = open(f&#039;book\/{id_info}.txt&#039;, &#039;a&#039;, encoding=&#039;utf-8&#039;)\n    for i in range(1,41):\n        book_count_url = f&#039;https:\/\/b.faloo.com\/{id_info}_{i}.html&#039;\n        headers ={\n            &#039;user-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&#039;,\n            &#039;cookie&#039;:&#039;host4chongzhi=b.faloo.com; readline=1; fontFamily=1; fontsize=16; vip_img_width=3; font_Color=666666; nc_rela=2; novelrelative=1458703; favorates28=1458703%2C2%7C1436865%2C4; autobuychapters28=1458703%2C2%7C1436865%2C4; bgcolor=%23FFFFFE; curr_url=https%3A\/\/b.faloo.com\/1436865.html%3F1&#039;,\n\n        }\n        book_count_res = requests.get(url=book_count_url, headers=headers)\n        book_count_html = etree.HTML(book_count_res.text)\n        text = tuple(map(lambda x:x+&#039;n&#039;,book_count_html.xpath(&#039;\/\/div[@class=&quot;noveContent&quot;]\/p\/text()&#039;)))\n        f.writelines(text)\n\nif __name__ == &#039;__main__&#039;:\n    book_id_info = book_id()\n    tasks = [Thread(target=book_count,args=(i,)) for i in book_id_info]\n    for i in tasks:\n        i.start()\n    for i in tasks:\n        i.join()\n<\/code><\/pre>\n<h3>2.\u5f02\u6b65-\u534f\u7a0b<\/h3>\n<h4>\u5f02\u6b65\u7684\u4f7f\u7528<\/h4>\n<blockquote>\n<p>\u53ea\u7528\u4e8e\u4e00\u4e2a\u573a\u666f&#8211;&gt;\u7b49\u5f85IO\uff0c\u9047\u5230IO\u5c31\u5207\u6362\u5230\u4e0b\u4e00\u4e2a\u4efb\u52a1<\/p>\n<\/blockquote>\n<pre><code class=\"language-python\">import asyncio  # \u5f02\u6b65\u6a21\u5757\n\n# \u58f0\u660e\u5f02\u6b65\u51fd\u6570\nasync def count(x):\n    # await \u6807\u8bb0\u9700\u8981\u7b49\u5f85\u7684IO\u64cd\u4f5c\n    await asyncio.sleep(1)\n    print(x)\n\n# \u5f02\u6b65\u5bb9\u5668  \u4efb\u52a1\u8868\nloop = asyncio.new_event_loop()\n# \u542f\u52a8\u4efb\u52a1(\u5355\u6b21)\n# loop.run_until_complete(count(1))\n# \u542f\u52a8\u4efb\u52a1(\u591a\u6b21)\nap = [loop.create_task(count(i)) for i in range(10)]\nloop.run_until_complete(asyncio.wait(ap))\n<\/code><\/pre>\n<h4>\u5b9e\u6218<\/h4>\n<p>\u4f7f\u7528\u5f02\u6b65\u5bf9<a href=\"https:\/\/cs.ganji.com\/tech\/pn1\/\">\u8d76\u96c6\u62db\u8058<\/a>\u4e2d\u7684\u6570\u636e\u8fdb\u884c\u722c\u53d6<\/p>\n<p>\u9700\u8981\u5bfc\u5165\u5f02\u6b65\u8bf7\u6c42\u6a21\u5757<\/p>\n<pre><code class=\"language-shell\">pip install aiohttp\n<\/code><\/pre>\n<pre><code class=\"language-python\">import asyncio\nimport aiohttp\nfrom lxml import etree\n\nasync def download(page:int):\n    url = f&#039;https:\/\/cs.ganji.com\/tech\/pn{page}\/&#039;\n    headers ={\n        &#039;user-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/143.0.0.0 Safari\/537.36&#039;,\n        &#039;cookie&#039;:&#039;id58=CkwAG2lvK0U6FAFwEvZYAg==; 58tj_uuid=dac3aab2-2276-469e-a743-f8b8d18f8420; ngj_city_id=2; ngj_city_name=%E4%B8%8A%E6%B5%B7; ngj_city_listname=sh; new_uv=2&#039;,\n\n    }\n    async with aiohttp.ClientSession() as session:\n        # \u4f7f\u7528\u4ee3\u7406\u7684\u5199\u6cd5\n        # async with session.get(url, headers=headers, proxy=&#039;http:\/\/\u4ee3\u7406ip:\u7aef\u53e3\u53f7&#039;) as res:\n        async with session.get(url, headers=headers) as res:\n            # text()\u5b57\u7b26\u4e32\n            # read()\u4e8c\u8fdb\u5236\u6570\u636e\n            # json()\u7684json\u7c7b\u578b\u7684\u6570\u636e\n            text = await res.text()\n            return text\n# \u65e0\u6cd5\u76f4\u63a5\u89e3\u6790\u6570\u636e\n# loop = asyncio.new_event_loop()\n# tasks = [loop.create_task(download(i)) for i in range(1,11)]\n# loop.run_until_complete(asyncio.wait(tasks))\n\n# \u89e3\u6790\u51fd\u6570\ndef func(fut):\n    result = fut.result()\n    html = etree.HTML(result)\n    a_all = html.xpath(&#039;\/\/div[@class=&quot;position&quot;]\/div[4]\/div\/a[@class=&quot;ibox&quot;]&#039;)\n    # \u6807\u9898\n    title = tuple(map(lambda x:x.xpath(&#039;.\/ul[1]\/li[1]\/text()&#039;)[0],a_all))\n    # \u85aa\u6c34\n    salary = tuple(map(lambda x:&#039;&#039;.join(x.xpath(&#039;.\/ul[1]\/li[2]\/\/text()&#039;)).strip(&#039;n &#039;),a_all))\n    # \u6807\u7b7e\n    label = tuple(map(lambda x:&#039;\/&#039;.join(x.xpath(&#039;.\/ul[1]\/div\/span\/span\/text()&#039;)),a_all))\n    # \u516c\u53f8\n    company = tuple(map(lambda x: x.xpath(&#039;.\/ul[2]\/li[1]\/object\/a\/text()&#039;)[0].strip(&#039;n &#039;), a_all))\n    # \u5730\u5740\n    address = tuple(map(lambda x:&#039;&#039;.join(x.xpath(&#039;.\/ul[2]\/li[2]\/\/text()&#039;)).strip(&#039;n &#039;).replace(&#039; | &#039;,&#039;\uff5c&#039;),a_all))\n    # \u62fc\u63a5\u6570\u636e\n    data = tuple(map(lambda x:(x[1],salary[x[0]],label[x[0]],company[x[0]],address[x[0]]), enumerate(title)))\n    pass\n\n# \u5206\u914d\u4efb\u52a1\u7684\u5f02\u6b65\u51fd\u6570\nasync def main():\n    tasks = list()\n    for page in range(1,11):\n        c = download(page)  # \u521b\u5efa\u534f\u7a0b\u5bf9\u8c61\n        task = asyncio.ensure_future(c)     # \u5c06\u4efb\u52a1\u5bf9\u8c61\u8fdb\u884c\u5f02\u6b65\u5c01\u88c5\n        task.add_done_callback(func)    # \u6307\u5b9a\u56de\u8c03\u51fd\u6570\n        tasks.append(task)\n    await asyncio.gather(*tasks)\n\nif __name__ == &#039;__main__&#039;:\n    asyncio.run(main())\n<\/code><\/pre>\n<h2>\u5341\u3001selenium<\/h2>\n<h3>1.selenium\u5de5\u5177\u51c6\u5907<\/h3>\n<ul>\n<li>\n<p>Chrome\u6d4f\u89c8\u5668<\/p>\n<\/li>\n<li>\n<p>Chrome\u9a71\u52a8<\/p>\n<p>\u4e0b\u8f7d\u5730\u5740\uff1a<a href=\"https:\/\/googlechromelabs.github.io\/chrome-for-testing\/\">https:\/\/googlechromelabs.github.io\/chrome-for-testing\/<\/a><\/p>\n<\/li>\n<li>\n<p>\u9a71\u52a8\u7248\u672c\u67e5\u770b<\/p>\n<p>Chrome\u6d4f\u89c8\u5668\u5730\u5740\u680f\u8f93\u5165:<code>chrome:\/\/version<\/code><\/p>\n<\/li>\n<\/ul>\n<h3>2.selenium\u7684\u4f7f\u7528<\/h3>\n<p>\u9700\u8981\u5b89\u88c5\u7b2c\u4e09\u65b9\u6a21\u5757<\/p>\n<pre><code class=\"language-shell\">pip install selenium\n<\/code><\/pre>\n<p>\u5f53\u4f7f\u7528selenium\u8fd9\u79cd\u81ea\u52a8\u5316\u7a0b\u5e8f\u65f6\uff0c\u4f1a\u6709\u5bf9\u5e94\u7684\u201c\u6307\u7eb9\u201d\u4fe1\u606f<\/p>\n<p>\u5728\u7f51\u9875\u63a7\u5236\u53f0\u7ec8\u7aef\u8f93\u5165\uff1a<\/p>\n<pre><code class=\"language-shell\">navigator.webdriver\n<\/code><\/pre>\n<p>\u53cd\u68c0\u6d4b\u6a21\u5757<\/p>\n<pre><code class=\"language-shell\">pip install undetected_chromedriver\n<\/code><\/pre>\n<h4>\u793a\u4f8b<\/h4>\n<pre><code class=\"language-python\">from selenium import webdriver\nimport undetected_chromedriver as webdriver_1\n\n# \u4f7f\u7528\u4ee3\u7406\noptions = webdriver.ChromeOptions()\noptions.add_argument(&#039;--proxy-server=socks4:\/\/39.104.16.201:3128&#039;)\n\nchrome = webdriver_1.Chrome()\n# \u6ce8\uff1a\u5728\u8fd0\u884c\u524d\u5c3d\u91cf\u5173\u95ed\u6240\u6709Google\u6d4f\u89c8\u5668\nchrome.get(&#039;https:\/\/www.youku.com\/ku\/webhome&#039;)\n\ninput()\n<\/code><\/pre>\n<h2>\u5341\u4e00\u3001Scrapy\u6846\u67b6\u57fa\u7840<\/h2>\n<h3>1.Scrapy\u6846\u67b6<\/h3>\n<p>Scrapy\u722c\u866b\u6846\u67b6\u662f\u57fa\u4e8e\u5f02\u6b65\u7684\u722c\u866b\u6846\u67b6<\/p>\n<p>\u4e3b\u8981\u5c01\u88c5\u7684\u7684\u529f\u80fd\uff1a\u591a\u7ebf\u7a0b+\u5f02\u6b65\u64cd\u4f5c(twisted\u7f51\u7edc\u5f02\u6b65\u901a\u4fe1\u67b6\u6784)<br \/>\u591a\u673a\u534f\u540c\u5de5\u4f5c(redis\u670d\u52a1)<\/p>\n<p>Scrapy\u6846\u67b6\u662f\u4e00\u4e2a\u5b8c\u6574\u7684\u722c\u866b<\/p>\n<p>\u5b8c\u6574\u7684\u722c\u866b\u5305\u62ec\uff1a\u722c\u866b\u6784\u9020\uff0c\u6570\u636e\u83b7\u53d6\uff0c\u6570\u636e\u5e93\u521d\u59cb\u5316\uff0c\u6570\u636e\u4fdd\u5b58<\/p>\n<h3>2.\u6a21\u5757\u51c6\u5907<\/h3>\n<pre><code class=\"language-shell\">pip install scrapy\n<\/code><\/pre>\n<h3>3. \u6846\u67b6\u7684\u4f7f\u7528<\/h3>\n<h4>\u521b\u5efa\u9879\u76ee<\/h4>\n<pre><code class=\"language-shell\">scrapy startproject \u9879\u76ee\u540d\n<\/code><\/pre>\n<h4>\u9879\u76ee\u8bbe\u7f6e<\/h4>\n<h4>\u6784\u5efa\u722c\u866b<\/h4>\n<h4>\u6570\u636e\u5b58\u50a8<\/h4>\n<h2>\u5341\u4e8c\u3001js\u9006\u5411-\u4ee3\u7801\u53cd\u7f16\u8bd1<\/h2>\n<p>\u6848\u4f8b\u7f51\u5740\uff1a<a href=\"https:\/\/www.oklink.com\/zh-hans\/bitcoin\/block-list\">oklink<\/a><\/p>\n<h3>1.js\u9006\u5411<\/h3>\n<p>\u6709\u4e9b\u7f51\u7ad9\u4e0d\u4ec5\u4ec5\u901a\u8fc7\u4e00\u4e9b\u5e38\u89c4\u5b57\u6bb5\u6765\u8fdb\u884c\u8eab\u4efd\u68c0\u9a8c\uff0c\u5982\uff1acookie\u3001sessionid\uff0c\u56e0\u4e3a\u8fd9\u4e9b\u5e38\u89c1\u5b57\u6bb5\u5177\u6709\u4e00\u5b9a\u7f3a\u9677\uff0c\u90a3\u4e48\u6b64\u65f6\u5c31\u4f1a\u7531\u524d\u7aefjs\u4ee3\u7801\u6765\u751f\u6210\u4e00\u4e2a\u5bf9\u5e94\u7684\u6821\u9a8c\u5b57\u6bb5\uff0c\u6765\u8fdb\u884c\u8eab\u4efd\u6821\u9a8c\uff0c\u8fd9\u79cd\u6821\u9a8c\u662f\u7b97\u6cd5\u7684\u6821\u9a8c\u3002<\/p>\n<blockquote>\n<p>x-apikey\u6bd4\u8f83\uff1a<\/p>\n<p>LWIzMWUtNDU0Ny05Mjk5LWI2ZDA3Yjc2MzFhYmEyYzkwM2NjfDI4ODAxODAzNDA1MzAzMTA=<\/p>\n<p>3Yjc2MzFhYmEyYzkwM2NjfDI4ODAxODA2MzE5NTY5MTE=<\/p>\n<\/blockquote>\n<p>\u5f53\u770b\u5230\u67d0\u4e2a\u52a0\u5bc6\u5b57\u6bb5\u6bcf\u6b21\u90fd\u4f1a\u53d8\u5316\uff0c\u4f46\u4f1a\u6709\u4e00\u6bb5\u59cb\u7ec8\u4e0d\u53d8\uff0c\u53ef\u4ee5\u63a8\u65ad\u5b83\u662f\u4e00\u4e2a\u7b7e\u540d\u7b97\u6cd5<\/p>\n<p>\u7b7e\u540d\u7b97\u6cd5\uff1a\u7531\u4e00\u4e2a\u6216\u8005\u591a\u4e2a\u53d8\u5316\u7684\u503c\uff0c\u52a0\u4e0a\u56fa\u5b9a\u503c[\u76d0]\uff0c\u901a\u8fc7\u52a0\u5bc6\u7b97\u6cd5\u5f97\u6765<\/p>\n<h3>2.\u5bfb\u627e\u76ee\u6807\u4f4d\u7f6e<\/h3>\n<p><kbd>Ctrl<\/kbd>+<kbd>shift<\/kbd>+<kbd>f<\/kbd>\u8fdb\u884c\u67e5\u627e<\/p>\n<p>\u8fd9\u4e9b\u6570\u636e\u662f\u901a\u8fc7\u52a0\u5bc6\u7b97\u6cd5\u6765\u7684\uff1a\u770b\u641c\u7d22\u51fa\u6765\u7684\u4e0a\u4e0b\u6587\u5f53\u4e2d\u662f\u5426\u5305\u542b[parse\u3001encrypt\u3001md5\u3001rsa\u3001aes]\u8fd9\u7c7b\u578b\u7684\u5b57\u7b26<\/p>\n<p>\u5f97\u5230\u7684js\u4ee3\u7801<\/p>\n<pre><code class=\"language-js\">function getApiKey() {\n    var e = (new Date).getTime(), t = encryptApiKey();\n    return e = encryptTime(e),\n    comb(t, e)\n}\nAPI_KEY = &quot;a2c903cc-b31e-4547-9299-b6d07b7631ab&quot;\nfunction encryptApiKey() {\n    var e = API_KEY, t = e.split(&quot;&quot;), n = t.splice(0, 8);\n    return e = t.concat(n).join(&quot;&quot;)\n}\n\nfunction encryptTime(e) {\n    var t = (1 * e + s).toString().split(&quot;&quot;)\n        , n = parseInt(10 * o.o.mathRandom(), 10)\n        , r = parseInt(10 * o.o.mathRandom(), 10)\n        , i = parseInt(10 * o.o.mathRandom(), 10);\n    return t.concat([n, r, i]).join(&quot;&quot;)\n}\n\nfunction comb(e, t) {\n    var n = &quot;&quot;.concat(e, &quot;|&quot;).concat(t);\n    return a.A.btoa(n)\n}\n<\/code><\/pre>\n<p>\u8f6c\u6362\u540e<\/p>\n<pre><code class=\"language-python\">from time import time\nfrom random import randint\nfrom base64 import b64encode\nimport requests\n\ndef getApiKey():\n    e = int(time()*1000)\n    t = encryptApiKey()\n    e = encryptTime(e)\n    apikey = comb(t, e)\n    return apikey\n\nAPI_KEY = &quot;a2c903cc-b31e-4547-9299-b6d07b7631ab&quot;\ndef encryptApiKey():\n    e = API_KEY\n    t = list(e)\n    n,t = t[:8],t[8:]\n    t.extend(n)\n    e = &#039;&#039;.join(t)\n    return e\n\ndef encryptTime(e):\n    t = list(str((1 * e + 1111111111111)))\n    n = str(randint(0,9))\n    r = str(randint(0,9))\n    i = str(randint(0,9))\n    t.extend([n,r,i])\n    return &#039;&#039;.join(t)\n\ndef comb(e, t):\n    n = f&#039;{e}|{t}&#039;\n    apikey = b64encode(n.encode()).decode()\n    return apikey\n\nkey = getApiKey()\n\nurl = f&#039;https:\/\/www.oklink.com\/api\/explorer\/v1\/btc\/blocks?offset=0&amp;limit=100&amp;t={int(time()*1000)}&#039;\nheaders ={\n    &#039;user-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/144.0.0.0 Safari\/537.36&#039;,\n    &#039;cookie&#039;:&#039;devId=db003635-abc4-45aa-94d4-3698e67bde1e; ok_site_info=9FjOikHdpRnblJCLiskTJx0SPJiOiUGZvNmIsIyUVJiOi42bpdWZyJye; locale=zh_CN; ok-exp-time=1769069055106; first_ref=https%3A%2F%2Fwww.qklw.com%2F; fingerprint_id=db003635-abc4-45aa-94d4-3698e67bde1e; fp_s=-1; okg.currentMedia=md; traceId=2020190762744410001; __cf_bm=fQb5tROqasRo6vByWpjb4JlO_2Xqq3HrpX0hnayvhkY-1769076274-1.0.1.1-HORhLlqOB6gzsJAlkGkDRb5KM4cQ1k.MzM8Ik0vN10Hdpgt3UEN7i44WjbxbpA78JfOq6gI0U2lZwiXklJHRn2seNJbwDLeYzS3uVD9Z8MQ; ok-ses-id=iVwVAiHXnes+wD\/HMLUOA0QIZ2QKUX9KZ18WRIIiM\/Tsdl6ALbbVAT\/kyOyxWCINLAy9JBLxKLbEEOKuiCMi2C2Gk\/vccjYy1+SQojTseDiF2IH2Yhdn4HfS5fVN\/zbP; _monitor_extras={&quot;deviceId&quot;:&quot;K7C9deCj86-hyeCzzPkH5t&quot;,&quot;eventId&quot;:98,&quot;sequenceNumber&quot;:98}&#039;,\n    &#039;x-apikey&#039;:key,\n    &#039;devid&#039;:&#039;db003635-abc4-45aa-94d4-3698e67bde1e&#039;\n}\nres = requests.get(url,headers=headers)\nres\n<\/code><\/pre>\n<h3>3.\u7ec3\u4e60<\/h3>\n<h4>vivo\u793e\u533a<\/h4>\n<p>\u4f7f\u7528js\u9006\u5411\u5bf9<a href=\"https:\/\/bbs.vivo.com.cn\/newbbs\/\">vivo\u793e\u533a<\/a>\u8fdb\u884c\u722c\u53d6<\/p>\n<h5>md5\u7684\u52a0\u5bc6\u7279\u5f81<\/h5>\n<ul>\n<li>\u4e0d\u53ef\u9006\u7684\u52a0\u5bc6\u7b97\u6cd5<\/li>\n<li>\u660e\u6587\u4e0e\u5bc6\u6587\u4e00\u5bf9\u4e00<\/li>\n<li>\u8fdb\u884c\u52a0\u5bc6\u540e\u7684\u7ed3\u679c\u4e3a32\u4f4d16\u8fdb\u5236\u7684\u5b57\u7b26\u7ec4\u6210==&gt;0-9,a-f<\/li>\n<\/ul>\n<pre><code class=\"language-python\">import requests\nimport json\nfrom hashlib import md5\nfrom time import time\nfrom random import randint\n\nfor page in range(1,11):\n    # js\n    # e. params.nonce = Object(je.md5)(n + &quot;&quot; + parseInt(1e7 * Math.random(), 10) + 1, 32)\n    times = int(time() * 1000)\n    nonce = md5(f&#039;{times}{randint(1000000, 9999999) + 1}&#039;.encode()).hexdigest()  # hexdigest()\u83b7\u53d632\u4f4d\u52a0\u5bc6\u7ed3\u679c\n\n    url = &#039;https:\/\/bbs.vivo.com.cn\/api\/community\/index&#039;\n    headers = {\n        &#039;user-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/144.0.0.0 Safari\/537.36&#039;,\n        &#039;cookie&#039;:&#039;cookieId=2af71ac1-d2eb-1171-be0a-a4da24190f7d1767335490049; sessionId=9ad7e8ac-3f6b-abc2-5611-caf9e978768f&#039;,\n        &#039;referer&#039;:&#039;https:\/\/bbs.vivo.com.cn\/newbbs\/&#039;,\n        &#039;content-type&#039;:&#039;application\/json;charset=UTF-8&#039;,\n    }\n    # \u56e0\u4e3a\u524d\u540e\u7aef\u6570\u636e\u4f20\u8f93\u9700\u8981\u7684\u662fjson\u683c\u5f0f\u7684\u6570\u636e\uff0c\u53ef\u80fd\u9700\u8981\u5bf9data\u8fdb\u884c\u5e8f\u5217\u5316\u64cd\u4f5c\n    data = json.dumps({&quot;lastId&quot;:&quot;&quot;,&quot;pageNum&quot;:page,&quot;pageSize&quot;:10,&quot;imgSpecs&quot;:[&quot;t577x324&quot;,&quot;t577x4096&quot;],&quot;timestamp&quot;:times,&quot;nonce&quot;:nonce})\n    res = requests.post(url,headers=headers,data=data)\n    res\n<\/code><\/pre>\n<h3>4.HOOK<\/h3>\n<p>\u56e0\u4e3a\u6709\u4e9b\u7f51\u7ad9\u4f1a\u5e72\u6270\u8c03\u8bd5\uff0c\u90a3\u4e48\u6b64\u65f6\u5c31\u9700\u8981\u8fdb\u884cHOOK\u6ce8\u5165\uff0c\u66ff\u6362\u5bf9\u5e94\u7684\u7d22\u5f15\u6587\u4ef6<\/p>\n<h4>HOOK\u6ce8\u5165<\/h4>\n<h2>\u5341\u4e09\u3001js\u9006\u5411-webpack<\/h2>\n<h3>1.\u5e38\u89c1\u7684\u52a0\u5bc6\u7b97\u6cd5<\/h3>\n<ul>\n<li>\n<p>\u7b7e\u540d\u7b97\u6cd5<\/p>\n<p>\u4e0d\u53ef\u9006\u7684\u52a0\u5bc6\u7b97\u6cd5\uff0c\u901a\u5e38\u660e\u6587\u548c\u5bc6\u6587\u662f\u4e00\u5bf9\u4e00\u5173\u7cfb\uff0c\u5728\u8fdb\u884c\u52a0\u5bc6\u7684\u65f6\u5019\uff0c\u5728\u660e\u6587\u524d\u540e\u52a0\u5165\u4e00\u4e9b\u56fa\u5b9a\u7684\u5b57\u7b26\u4e32(\u76d0)\u8fdb\u884c\u52a0\u5bc6==&gt;md5\u52a0\u5bc6\uff0csha\u7cfb\u5217<\/p>\n<ul>\n<li>MD5\u7684\u5bc6\u6587==&gt;16\u8fdb\u5236\u7684\u5b57\u7b26\u7ec4\u62100-9\uff0ca-f<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5<\/p>\n<p>\u53ef\u9006\u7684\u7b97\u6cd5\uff0c\u53ef\u4ee5\u52a0\u5bc6\u4e5f\u53ef\u4ee5\u89e3\u5bc6\uff0c\u660e\u6587\u548c\u5bc6\u6587\u4e4b\u95f4\u662f\u5bf9\u79f0\u7684\u5173\u7cfb\uff0c\u5bf9\u79f0\u52a0\u5bc6\u5f80\u5f80\u8981\u4f20\u51653\u4e2a\u53c2\u6570<\/p>\n<ul>\n<li>\n<p>\u660e\u6587(data\u3001messge)<\/p>\n<\/li>\n<li>\n<p>\u94a5\u5319(key)<\/p>\n<\/li>\n<li>\n<p>\u504f\u79fb\u91cf(iv)<\/p>\n<p>aes\u3001des,\u52a0\u5bc6\u540e\u7684\u5185\u5bb9==&gt;<code>a-z,A-Z,0-9,+,\/,=<\/code><\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>\u975e\u5bf9\u79f0\u52a0\u5bc6\u7b97\u6cd5<\/p>\n<p>\u660e\u6587\u548c\u5bc6\u6587\u5b58\u5728\u4e00\u5bf9\u591a\u7684\u5173\u7cfb\uff0c\u53ef\u4ee5\u89e3\u5bc6\uff0c\u4f1a\u5b58\u5728\u79c1\u94a5\u3001\u516c\u94a5\uff0c\u516c\u94a5\u53ea\u80fd\u7528\u6765\u52a0\u5bc6\uff0c\u79c1\u94a5\u7528\u6765\u89e3\u5bc6<\/p>\n<\/li>\n<\/ul>\n<h3>2.python\u8c03\u7528js\u4ee3\u7801<\/h3>\n<p><strong>\u6a21\u5757\u51c6\u5907<\/strong>\uff1a<code>pyexecjs<\/code><\/p>\n<pre><code class=\"language-shell\">pip install pyexecjs\n<\/code><\/pre>\n<h4>execjs\u6a21\u5757\u4f7f\u7528\u793a\u4f8b<\/h4>\n<pre><code class=\"language-js\">function a(x,y){\n    return x+y;\n}\n<\/code><\/pre>\n<pre><code class=\"language-python\"># \u5bfc\u5165\u6a21\u5757\nimport execjs\n\n# \u52a0\u8f7djs\u4ee3\u7801\nwith open(&#039;text.js&#039;, &#039;r&#039;, encoding=&#039;utf-8&#039;) as f:\n    nodejs = f.read()\n\n# \u8f6c\u6362\u4e3a\u53ef\u6267\u884c\u7684\u4ee3\u7801\nctx = execjs.compile(nodejs)\n# call\u65b9\u6cd5\uff1a\u8c03\u7528js\u4e2d\u7684\u51fd\u6570\uff0c\u53c2\u65701\uff1a\u51fd\u6570\u540d\uff0c\u53c2\u65702\uff1a\u4f20\u5165\u503c\na = ctx.call(&#039;a&#039;,3,5)\nprint(a)\n# 8\n<\/code><\/pre>\n<h4>\u6848\u4f8b\u5c55\u793a<\/h4>\n<h5>1.oklink<\/h5>\n<pre><code class=\"language-js\">API_KEY = &quot;a2c903cc-b31e-4547-9299-b6d07b7631ab&quot;\nfunction encryptApiKey() {\n    var e = API_KEY\n        , t = e.split(&quot;&quot;)\n        , r = t.splice(0, 8);\n    return e = t.concat(r).join(&quot;&quot;)\n}\np = 1111111111111\nfunction encryptTime(e) {\n    var t = (1 * e + p).toString().split(&quot;&quot;)\n        , r = parseInt(10 * Math.random(), 10)\n        , n = parseInt(10 * Math.random(), 10)\n        , o = parseInt(10 * Math.random(), 10);\n    return t.concat([r, n, o]).join(&quot;&quot;)\n}\n\nfunction comb(e, t) {\n    var r = &quot;&quot;.concat(e, &quot;|&quot;).concat(t);\n    return Buffer(r).toString(&#039;base64&#039;)\n}\n\nfunction getApiKey() {\n    var e = (new Date).getTime()\n        , t = encryptApiKey();\n    return e = encryptTime(e),\n    comb(t, e)\n}\n<\/code><\/pre>\n<pre><code class=\"language-python\">import execjs\n\nwith open(&#039;oklink.js&#039;,&#039;r&#039;,encoding=&#039;utf-8&#039;) as f:\n    nodejs = f.read()\n\nctx = execjs.compile(nodejs)\na = ctx.call(&#039;getApiKey&#039;)\nprint(a)\n<\/code><\/pre>\n<h5>2.vivo\u793e\u533a<\/h5>\n<pre><code class=\"language-js\">var n = Date.now();\n\nfunction md5(e, t) {\n    function r(e, t) {\n        return e &lt;&lt; t | e &gt;&gt;&gt; 32 - t\n    }\n    function n(e, t) {\n        var r, n, u, o, l;\n        return u = 2147483648 &amp; e,\n        o = 2147483648 &amp; t,\n        l = (1073741823 &amp; e) + (1073741823 &amp; t),\n        (r = 1073741824 &amp; e) &amp; (n = 1073741824 &amp; t) ? 2147483648 ^ l ^ u ^ o : r | n ? 1073741824 &amp; l ? 3221225472 ^ l ^ u ^ o : 1073741824 ^ l ^ u ^ o : l ^ u ^ o\n    }\n    function u(e, t, u, o, l, i, c) {\n        return e = n(e, n(n(function(e, t, r) {\n            return e &amp; t | ~e &amp; r\n        }(t, u, o), l), c)),\n        n(r(e, i), t)\n    }\n    function o(e, t, u, o, l, i, c) {\n        return e = n(e, n(n(function(e, t, r) {\n            return e &amp; r | t &amp; ~r\n        }(t, u, o), l), c)),\n        n(r(e, i), t)\n    }\n    function l(e, t, u, o, l, i, c) {\n        return e = n(e, n(n(function(e, t, r) {\n            return e ^ t ^ r\n        }(t, u, o), l), c)),\n        n(r(e, i), t)\n    }\n    function i(e, t, u, o, l, i, c) {\n        return e = n(e, n(n(function(e, t, r) {\n            return t ^ (e | ~r)\n        }(t, u, o), l), c)),\n        n(r(e, i), t)\n    }\n    function c(e) {\n        var t, r = &quot;&quot;, n = &quot;&quot;;\n        for (t = 0; t &lt;= 3; t++)\n            r += (n = &quot;0&quot; + (e &gt;&gt;&gt; 8 * t &amp; 255).toString(16)).substr(n.length - 2, 2);\n        return r\n    }\n    var d, a, s, p, f, h, m, A, g, v = e, b = Array();\n    for (b = function(e) {\n        for (var t, r = e.length, n = r + 8, u = 16 * ((n - n % 64) \/ 64 + 1), o = Array(u - 1), l = 0, i = 0; i &lt; r; )\n            l = i % 4 * 8,\n            o[t = (i - i % 4) \/ 4] = o[t] | e.charCodeAt(i) &lt;&lt; l,\n            i++;\n        return l = i % 4 * 8,\n        o[t = (i - i % 4) \/ 4] = o[t] | 128 &lt;&lt; l,\n        o[u - 2] = r &lt;&lt; 3,\n        o[u - 1] = r &gt;&gt;&gt; 29,\n        o\n    }(v),\n    h = 1732584193,\n    m = 4023233417,\n    A = 2562383102,\n    g = 271733878,\n    d = 0; d &lt; b.length; d += 16)\n        a = h,\n        s = m,\n        p = A,\n        f = g,\n        m = i(m = i(m = i(m = i(m = l(m = l(m = l(m = l(m = o(m = o(m = o(m = o(m = u(m = u(m = u(m = u(m, A = u(A, g = u(g, h = u(h, m, A, g, b[d + 0], 7, 3614090360), m, A, b[d + 1], 12, 3905402710), h, m, b[d + 2], 17, 606105819), g, h, b[d + 3], 22, 3250441966), A = u(A, g = u(g, h = u(h, m, A, g, b[d + 4], 7, 4118548399), m, A, b[d + 5], 12, 1200080426), h, m, b[d + 6], 17, 2821735955), g, h, b[d + 7], 22, 4249261313), A = u(A, g = u(g, h = u(h, m, A, g, b[d + 8], 7, 1770035416), m, A, b[d + 9], 12, 2336552879), h, m, b[d + 10], 17, 4294925233), g, h, b[d + 11], 22, 2304563134), A = u(A, g = u(g, h = u(h, m, A, g, b[d + 12], 7, 1804603682), m, A, b[d + 13], 12, 4254626195), h, m, b[d + 14], 17, 2792965006), g, h, b[d + 15], 22, 1236535329), A = o(A, g = o(g, h = o(h, m, A, g, b[d + 1], 5, 4129170786), m, A, b[d + 6], 9, 3225465664), h, m, b[d + 11], 14, 643717713), g, h, b[d + 0], 20, 3921069994), A = o(A, g = o(g, h = o(h, m, A, g, b[d + 5], 5, 3593408605), m, A, b[d + 10], 9, 38016083), h, m, b[d + 15], 14, 3634488961), g, h, b[d + 4], 20, 3889429448), A = o(A, g = o(g, h = o(h, m, A, g, b[d + 9], 5, 568446438), m, A, b[d + 14], 9, 3275163606), h, m, b[d + 3], 14, 4107603335), g, h, b[d + 8], 20, 1163531501), A = o(A, g = o(g, h = o(h, m, A, g, b[d + 13], 5, 2850285829), m, A, b[d + 2], 9, 4243563512), h, m, b[d + 7], 14, 1735328473), g, h, b[d + 12], 20, 2368359562), A = l(A, g = l(g, h = l(h, m, A, g, b[d + 5], 4, 4294588738), m, A, b[d + 8], 11, 2272392833), h, m, b[d + 11], 16, 1839030562), g, h, b[d + 14], 23, 4259657740), A = l(A, g = l(g, h = l(h, m, A, g, b[d + 1], 4, 2763975236), m, A, b[d + 4], 11, 1272893353), h, m, b[d + 7], 16, 4139469664), g, h, b[d + 10], 23, 3200236656), A = l(A, g = l(g, h = l(h, m, A, g, b[d + 13], 4, 681279174), m, A, b[d + 0], 11, 3936430074), h, m, b[d + 3], 16, 3572445317), g, h, b[d + 6], 23, 76029189), A = l(A, g = l(g, h = l(h, m, A, g, b[d + 9], 4, 3654602809), m, A, b[d + 12], 11, 3873151461), h, m, b[d + 15], 16, 530742520), g, h, b[d + 2], 23, 3299628645), A = i(A, g = i(g, h = i(h, m, A, g, b[d + 0], 6, 4096336452), m, A, b[d + 7], 10, 1126891415), h, m, b[d + 14], 15, 2878612391), g, h, b[d + 5], 21, 4237533241), A = i(A, g = i(g, h = i(h, m, A, g, b[d + 12], 6, 1700485571), m, A, b[d + 3], 10, 2399980690), h, m, b[d + 10], 15, 4293915773), g, h, b[d + 1], 21, 2240044497), A = i(A, g = i(g, h = i(h, m, A, g, b[d + 8], 6, 1873313359), m, A, b[d + 15], 10, 4264355552), h, m, b[d + 6], 15, 2734768916), g, h, b[d + 13], 21, 1309151649), A = i(A, g = i(g, h = i(h, m, A, g, b[d + 4], 6, 4149444226), m, A, b[d + 11], 10, 3174756917), h, m, b[d + 2], 15, 718787259), g, h, b[d + 9], 21, 3951481745),\n        h = n(h, a),\n        m = n(m, s),\n        A = n(A, p),\n        g = n(g, f);\n    return 32 == t ? c(h) + c(m) + c(A) + c(g) : c(m) + c(A)\n}\n\nfunction res(){\n    data = md5(n + &quot;&quot; + parseInt(1e7 * Math.random(), 10) + 1, 32)\n    return data;\n}\n\nconsole.log(res())\n<\/code><\/pre>\n<pre><code class=\"language-python\">import execjs\n\nwith open(&#039;vivo.js&#039;,&#039;r&#039;,encoding=&#039;utf-8&#039;) as f:\n    nodejs = f.read()\n\nctx = execjs.compile(nodejs)\na = ctx.call(&#039;res&#039;)\nprint(a)\n<\/code><\/pre>\n<h3>3.webpack<\/h3>\n<p>\u4ee3\u7801\u5bb9\u5668&#8212;-\u56e0\u4e3a\u4e00\u4e2a\u5b9e\u9645\u7684\u6a21\u5757\u5f53\u4e2d\u5b58\u5728\u975e\u5e38\u591a\u7684\u65b9\u6cd5\uff0c\u5e76\u4e14\u6709\u53ef\u80fd\u5b58\u5728\u76f8\u4e92\u53cd\u590d\u7684\u8c03\u7528\uff0c\u6240\u4ee5\u6211\u4eec\u4e0d\u80fd\u4fdd\u8bc1\u4e00\u4e2a\u4e00\u4e2a\u53bb\u627e\u5230\uff0c\u6240\u6709\u7684\u914d\u7f6e\u51fd\u6570\uff0c\u56e0\u6b64\u5e94\u8be5\u627e\u5230\u8c03\u7528\u8fd9\u4e2a\u52a0\u5bc6\u51fd\u6570\u7684\u4ee3\u7801\u5bb9\u5668\u6765\u8fdb\u884c\u6267\u884c\u5f53\u4e2d\u7684\u4ee3\u7801<\/p>\n<blockquote>\n<p>Promise(\u51fd\u6570)-then(\u53c2\u6570)<\/p>\n<pre><code class=\"language-js\">Promise(function).then(x)\n<\/code><\/pre>\n<p>Promise\u91cc\u9762\u7684function\u51fd\u6570\u7684\u7ed3\u679c\u4f1a\u4f20\u5165\u5230then\u65b9\u6cd5\u7684\u53c2\u6570\u5f53\u4e2d<\/p>\n<\/blockquote>\n<h2>\u5341\u56db\u3001\u6ed1\u5757\u9a8c\u8bc1\u7801<\/h2>\n<p>\u9a8c\u8bc1\u7801\u662f\u901a\u8fc7\u4ec0\u4e48\u6765\u6821\u9a8c\u7684<\/p>\n<table>\n<thead>\n<tr>\n<th>ID<\/th>\n<th>data<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td>abc01<\/td>\n<td>170px-175px<\/td>\n<\/tr>\n<tr>\n<td><\/td>\n<td><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>1.\u6848\u4f8b<\/h3>\n<p>\u6848\u4f8b\u7f51\u5740\uff1a<a href=\"https:\/\/cszg.mca.gov.cn\/platform\/login.html?service=%2Fj_spring_security_check&amp;renew=true\">\u6148\u5584\u4e2d\u56fd<\/a><\/p>\n<h4>\u6e05\u9664\u7f51\u7ad9cookie<\/h4>\n<p><kbd>\u5e94\u7528<\/kbd>&#8211;&gt;<kbd>cookie<\/kbd>&#8211;&gt;\u53f3\u952e<kbd>\u6e05\u9664<\/kbd><\/p>\n<h3>2.ddddocr<\/h3>\n<p>\u4e0b\u8f7dddddocr\u6a21\u5757<\/p>\n<pre><code class=\"language-shell\">pip install ddddocr\n<\/code><\/pre>\n<h4>\u5b9e\u4f8b<\/h4>\n<pre><code class=\"language-python\">import requests\nfrom ddddocr import DdddOcr\nfrom base64 import b64decode,b64encode\n\n# \u521b\u5efaocr\u5b9e\u4f8b\n# ocr:\u68c0\u6d4b\u6587\u5b57\n# det:\u7528\u4f5c\u76ee\u6807\u68c0\u6d4b\uff0c\u5982\u626b\u7801\nocr = DdddOcr(ocr=False,det=False)\n\nget_img_url = &#039;https:\/\/cszg.mca.gov.cn\/biz\/ma\/csmh\/filter\/getSlideCaptcha.html&#039;\nimg_headers = {\n    &#039;user-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/144.0.0.0 Safari\/537.36&#039;\n}\nimg_res = requests.get(get_img_url, headers=img_headers)\noriImage,cutImage = img_res.json().get(&#039;c&#039;).get(&#039;oriImage&#039;),img_res.json().get(&#039;c&#039;).get(&#039;cutImage&#039;)\nori_img,cut_img = b64decode(oriImage),b64decode(cutImage)\nwith open(f&#039;img\/ori_img.png&#039;, &#039;wb&#039;) as f:\n    f.write(ori_img)\n\nwith open(f&#039;img\/cut_img.png&#039;, &#039;wb&#039;) as f:\n    f.write(cut_img)\n\nposition = ocr.slide_match(cut_img,ori_img,simple_target=True)[&#039;target&#039;]\nprint(position)\nx1,y1,x2,y2 = position\n\nslide_cap_url = f&#039;https:\/\/cszg.mca.gov.cn\/biz\/ma\/csmh\/filter\/slideCaptchaCheck.html?slidevalue={b64encode(str(x1).encode()).decode()}&#039;\nslide_cap_headers = {\n    &#039;user-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/144.0.0.0 Safari\/537.36&#039;,\n    &#039;cookie&#039;:f&#039;https_waf_cookie=92fbb60c-23e4-4884d27f5352a8a01883cce7d8f068eed942; JSESSIONID={img_res.cookies.get(&#039;JSESSIONID&#039;)}&#039;,\n\n}\nslide_cap_res = requests.get(slide_cap_url, headers=slide_cap_headers)\nprint(slide_cap_res.json())\n<\/code><\/pre>\n<h3>3.opencv-python<\/h3>\n<p>\u4e0b\u8f7d\u6a21\u5757<\/p>\n<pre><code class=\"language-shell\">pip install opencv-python\n<\/code><\/pre>\n<pre><code class=\"language-python\">import cv2\n\n# \u8bfb\u53d6\u80cc\u666f\u56fe\u7247\u548c\u7f3a\u53e3\u56fe\u7247\ncut_img = cv2.imread(&#039;img\/cut_img.png&#039;)\nori_img = cv2.imread(&#039;img\/ori_img.png&#039;)\n# \u8bc6\u522b\u56fe\u7247\u8fb9\u7f18\ncut_edge = cv2.Canny(cut_img, 100, 200)\nori_edge = cv2.Canny(ori_img, 100, 200)\n# \u8f6c\u6362\u56fe\u7247\u683c\u5f0f\ncut_pic = cv2.cvtColor(cut_edge, cv2.COLOR_GRAY2BGRA)\nori_pic = cv2.cvtColor(ori_edge, cv2.COLOR_GRAY2BGRA)\n# \u7f3a\u53e3\u5339\u914d\nres = cv2.matchTemplate(ori_pic, cut_pic, cv2.TM_CCOEFF_NORMED)\n# \u5bfb\u627e\u6700\u4f73\u5339\u914d\nposition = cv2.minMaxLoc(res)\nprint(position)\n<\/code><\/pre>\n<h2>\u5341\u56db\u3001\u5b57\u4f53\u53cd\u722c<\/h2>\n<p>\u6848\u4f8b\u7f51\u5740\uff1a<a href=\"https:\/\/www.dongchedi.com\/usedcar\/x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x\">\u61c2\u8f66\u5e1d<\/a><\/p>\n<h3>1.\u5b57\u4f53\u53cd\u722c\u539f\u7406<\/h3>\n<p>\u5b9e\u9645\u6570\u636e\u662f\u7531\u4e00\u4e2a\u7f51\u7edc\u7f16\u7801\u6765\u8fdb\u884c\u5360\u4f4d\uff0c\u540e\u671f\u901a\u8fc7js\u811a\u672c\u53bb\u5c06\u5bf9\u5e94\u7684\u7f16\u7801\u66ff\u6362\u6210\u5bf9\u5e94\u7684\u201c\u5b57\u7b26\u201d<\/p>\n<p>\u5b57\u4f53\u67e5\u770b\u5de5\u5177:<a href=\"https:\/\/www.bejson.com\/ui\/font\/\">BEJSON<\/a><\/p>\n<pre><code class=\"language-python\">import requests\n\nurl = &#039;https:\/\/www.dongchedi.com\/motor\/pc\/sh\/sh_sku_list?aid=1839&amp;app_name=auto_web_pc&#039;\nheaders = {\n    &#039;cookie&#039;:&#039;ttwid=1%7Cl6DOgeb_8xSC-4cLqLudIpUdQ0bswFBs1wzOE0fOB9o%7C1769166483%7C20d2f5b5520bb67ac42cc9ab957ae1362bfcf71b73c2d4160f5bf3401b490443; tt_webid=7598512060565030462; tt_web_version=new; is_dev=false; is_boe=false; _ga=GA1.1.184307655.1769166485; x-web-secsdk-uid=a1d77778-418f-40c3-9a8b-bb34d7c0abfc; s_v_web_id=verify_mkqs1q83_vMr6oxVB_XxS7_4jEF_ApS1_9gubbliP4yXJ; city_name=%E9%95%BF%E6%B2%99; rit_city=%E9%95%BF%E6%B2%99; _ga_YB3EWSDTGF=GS2.1.s1769166485$o1$g1$t1769167384$j56$l0$h0&#039;,\n    &#039;user-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/144.0.0.0 Safari\/537.36&#039;,\n    &#039;referer&#039;:&#039;https:\/\/www.dongchedi.com\/usedcar\/x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-x-110000-x-x-x-x-x-x&#039;,\n    &#039;content-type&#039;:&#039;application\/x-www-form-urlencoded&#039;\n}\ndata = &#039;&amp;sh_city_name=\u5168\u56fd&amp;page=1&amp;limit=20&#039;\nres = requests.post(url, headers=headers, data=data)\nfont_dict = {\n    &#039;uE439&#039;:&#039;0&#039;,\n    &#039;uE54C&#039;:&#039;1&#039;,\n    &#039;uE463&#039;:&#039;2&#039;,\n    &#039;uE49D&#039;:&#039;3&#039;,\n    &#039;uE41D&#039;:&#039;4&#039;,\n    &#039;uE411&#039;:&#039;5&#039;,\n    &#039;uE534&#039;:&#039;6&#039;,\n    &#039;uE3EB&#039;:&#039;7&#039;,\n    &#039;uE4E3&#039;:&#039;8&#039;,\n    &#039;uE45D&#039;:&#039;9&#039;,\n    &#039;uE40A&#039;:&#039;\u4e07&#039;\n}\n\nsh_price = tuple(map(lambda x:x.get(&#039;sh_price&#039;),res.json().get(&#039;data&#039;).get(&#039;search_sh_sku_info_list&#039;)))\nsh_price = tuple(map(lambda x:x.split(&#039;.&#039;),sh_price))\nsh_Price = []\nfor i,f in sh_price:\n    I = &#039;&#039;\n    F = &#039;&#039;\n    for i_test in i:\n        I += font_dict[i_test]\n    for f_test in f:\n        F += font_dict[f_test]\n    sh_Price.append(I+&#039;.&#039;+F)\n\nofficial_price = tuple(map(lambda x:x.get(&#039;official_price&#039;),res.json().get(&#039;data&#039;).get(&#039;search_sh_sku_info_list&#039;)))\nofficial_price = tuple(map(lambda x:x.split(&#039;.&#039;),official_price))\nofficial_Price = []\nfor i,f in official_price:\n    I = &#039;&#039;\n    F = &#039;&#039;\n    for i_test in i:\n        I += font_dict[i_test]\n    for f_test in f:\n        F += font_dict[f_test]\n    official_Price.append(I+&#039;.&#039;+F)\n<\/code><\/pre>\n<h3>2.fontTools<\/h3>\n<p>\u6a21\u5757\u51c6\u5907<\/p>\n<pre><code class=\"language-shell\">pip install fontTools\n<\/code><\/pre>\n<p>\u6848\u4f8b\u7f51\u5740\uff1a<a href=\"https:\/\/www.maoyan.com\/board\/1?timeStamp=1769171630258&amp;channelId=40011&amp;index=3&amp;signKey=1d24f7401b38479cd153d6f6796692b2&amp;sVersion=1&amp;webdriver=false\">\u732b\u773c\u7535\u5f71-\u56fd\u5185\u7968\u623f\u699c<\/a><\/p>\n<pre><code class=\"language-python\">import requests\nfrom fontTools.ttLib import TTFont  # \u52a0\u8f7d\u3001\u8bfb\u53d6\u539f\u59cb\u5b57\u4f53\u6587\u4ef6\u7684\u65b9\u6cd5\nfrom lxml import etree\n\n# \u8bfb\u53d6\u5b57\u4f53\u6587\u4ef6\nFont_Dict = dict()\nfont1  = TTFont(&#039;\u732b\u773cfont\/20a70494.woff&#039;)\n# \u4fdd\u5b58\u4e3aXML\u6587\u4ef6\nfont1.saveXML(&#039;\u732b\u773cfont\/20a70494.xml&#039;)\nindex1 = tuple(map(lambda x:x.lower().replace(&#039;uni&#039;,r&#039;u&#039;),font1.getGlyphOrder()[2:]))\nfont_dict1 = dict(zip(index1,[7,3,6,1,2,8,0,4,9,5]))\n\nfont2  = TTFont(&#039;\u732b\u773cfont\/e3dfe524.woff&#039;)\n# \u4fdd\u5b58\u4e3aXML\u6587\u4ef6\nfont2.saveXML(&#039;\u732b\u773cfont\/e3dfe524.xml&#039;)\nindex2 = tuple(map(lambda x:x.lower().replace(&#039;uni&#039;,r&#039;u&#039;),font2.getGlyphOrder()[2:]))\nfont_dict2 = dict(zip(index2,[9,2,4,1,5,3,6,8,0,7]))\n\nfont3  = TTFont(&#039;\u732b\u773cfont\/75e5b39d.woff&#039;)\n# \u4fdd\u5b58\u4e3aXML\u6587\u4ef6\nfont3.saveXML(&#039;\u732b\u773cfont\/75e5b39d.xml&#039;)\nindex3 = tuple(map(lambda x:x.lower().replace(&#039;uni&#039;,r&#039;u&#039;),font3.getGlyphOrder()[2:]))\nfont_dict3 = dict(zip(index3,[0,3,8,2,6,7,9,4,1,5]))\n\nfont4  = TTFont(&#039;\u732b\u773cfont\/2a70c44b.woff&#039;)\n# \u4fdd\u5b58\u4e3aXML\u6587\u4ef6\nfont4.saveXML(&#039;\u732b\u773cfont\/2a70c44b.xml&#039;)\nindex4 = tuple(map(lambda x:x.lower().replace(&#039;uni&#039;,r&#039;u&#039;),font4.getGlyphOrder()[2:]))\nfont_dict4 = dict(zip(index4,[7,5,3,9,0,2,6,4,1,8]))\nFont_Dict.update(font_dict1)\nFont_Dict.update(font_dict2)\nFont_Dict.update(font_dict3)\nFont_Dict.update(font_dict4)\n\n\n\nurl = &#039;https:\/\/www.maoyan.com\/board\/1&#039;\nheaders = {\n    &#039;user-agent&#039;:&#039;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/144.0.0.0 Safari\/537.36&#039;,\n    &#039;cookie&#039;:&#039;__mta=47143448.1767771051803.1769171627927.1769171630945.34; _lxsdk_cuid=19b975d6e6fc8-00450a48ddbee6-26061a51-1fa400-19b975d6e6fc8; uuid_n_v=v1; uuid=CA56C320EB9A11F09C6983D1745B13D9E85113618BC240D390361010F21FD821; _lxsdk=CA56C320EB9A11F09C6983D1745B13D9E85113618BC240D390361010F21FD821; _ga=GA1.1.1487119828.1767771051; _csrf=41b68d1e6a40d78c0860c78aa6776dce2b5ef4c99bf4e27f8ca934ccd6bafc18; global-guide-isclose=true; hotMovieIds=1478868,1322627,1498191,1142033,78463,1525137,1504573,338414,1487265,1422798,1355532,356895,1528369,1529812,1399234,1405509,1504556,1425266,1603579,1432807,1618267,1323,1573941,1535383,1299948,1572282,1614889,1548343,1502290,1428854,1547279,346650,1559720,1393510,1526767,1501173,1485017,376806,4430,247161,583,1502849,1302195,7284,285540,1295,1340,233631,32124,1487834,1528899; old-moviepage-ci=70; __mta=47143448.1767771051803.1769171570301.1769171591436.8; _lx_utm=utm_source%3DBaidu%26utm_medium%3Dorganic; _ga_WN80P4PSY7=GS2.1.s1769171394$o6$g1$t1769171630$j57$l0$h0; _lxsdk_s=19bead51e7d-5c-fbd-cda%7C%7C15&#039;,\n    &#039;referer&#039;:&#039;https:\/\/www.maoyan.com\/board\/4?timeStamp=1767789872419&amp;offset=0&#039;,\n}\n\nres = requests.get(url,headers=headers)\nres_html = etree.HTML(res.text)\nres\nrealtime = res_html.xpath(&#039;\/\/dl[@class=&quot;board-wrapper&quot;]\/dd\/div\/div\/div[2]\/p[1]\/span\/span\/text()&#039;)\ntotal_boxoffice = res_html.xpath(&#039;\/\/dl[@class=&quot;board-wrapper&quot;]\/dd\/div\/div\/div[2]\/p[2]\/span\/span\/text()&#039;)\nrealtime = tuple(map(lambda x:x.split(&#039;.&#039;), realtime))\ntotal_boxoffice = tuple(map(lambda x:x.split(&#039;.&#039;), total_boxoffice))\n\n# \u66ff\u6362\ndef replace(l,s:str):\n    L = []\n    for i,f in l:\n        I = &#039;&#039;\n        F = &#039;&#039;\n        for i_test in i:\n            I += str(Font_Dict[i_test.encode(&#039;unicode-escape&#039;).decode()])\n        for f_test in f:\n            F += str(Font_Dict[f_test.encode(&#039;unicode-escape&#039;).decode()])\n        L.append(I+s+F)\n    return L\n\nrealtime = replace(realtime,&#039;.&#039;)\ntotal_boxoffice = replace(total_boxoffice,&#039;.&#039;)\n\nprint(realtime)\nprint(total_boxoffice)\n<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>PDF\u4e0b\u8f7d\u5730\u5740\uff1a\u722c\u866bPDF \u4e00\u3001\u722c\u866b\u7b80\u4ecb 1.\u6a21\u5757\u51c6\u5907 requests lxml selenium scra [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":189,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2],"tags":[12,23],"class_list":["post-245","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","tag-python","tag-23"],"_links":{"self":[{"href":"http:\/\/blog.huihuia24.top\/index.php\/wp-json\/wp\/v2\/posts\/245","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/blog.huihuia24.top\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/blog.huihuia24.top\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/blog.huihuia24.top\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/blog.huihuia24.top\/index.php\/wp-json\/wp\/v2\/comments?post=245"}],"version-history":[{"count":2,"href":"http:\/\/blog.huihuia24.top\/index.php\/wp-json\/wp\/v2\/posts\/245\/revisions"}],"predecessor-version":[{"id":250,"href":"http:\/\/blog.huihuia24.top\/index.php\/wp-json\/wp\/v2\/posts\/245\/revisions\/250"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/blog.huihuia24.top\/index.php\/wp-json\/wp\/v2\/media\/189"}],"wp:attachment":[{"href":"http:\/\/blog.huihuia24.top\/index.php\/wp-json\/wp\/v2\/media?parent=245"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/blog.huihuia24.top\/index.php\/wp-json\/wp\/v2\/categories?post=245"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/blog.huihuia24.top\/index.php\/wp-json\/wp\/v2\/tags?post=245"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}