{"id":2872,"date":"2025-06-30T11:44:11","date_gmt":"2025-06-30T02:44:11","guid":{"rendered":"https:\/\/www.yilus5.com\/blog\/?p=2872"},"modified":"2025-06-30T11:44:13","modified_gmt":"2025-06-30T02:44:13","slug":"scrapy%e7%88%ac%e8%99%ab%e4%bb%a3%e7%90%86%e7%9a%84%e9%9f%a7%e6%80%a7%e4%b9%8b%e9%81%93%ef%bc%9a%e5%a6%82%e4%bd%95%e4%bc%98%e9%9b%85%e5%a4%84%e7%90%86bans%e3%80%81retries%e4%b8%8ecap","status":"publish","type":"post","link":"https:\/\/www.yilus5.com\/blog\/2872.html","title":{"rendered":"Scrapy\u722c\u866b\u4ee3\u7406\u7684\u201c\u97e7\u6027\u201d\u4e4b\u9053\uff1a\u5982\u4f55\u4f18\u96c5\u5904\u7406Bans\u3001Retries\u4e0eCAPTCHAs\uff1f"},"content":{"rendered":"\n<p>Scrapy\u4ee5\u5176\u5f3a\u5927\u7684\u5f02\u6b65\u6027\u80fd\uff0c\u6210\u4e3aPython\u722c\u866b\u9886\u57df\u7684\u5229\u5668\u3002\u7136\u800c\uff0c\u518d\u5feb\u7684\u201c\u5229\u5251\u201d\uff0c\u5728\u9762\u5bf9\u73b0\u4ee3\u7f51\u7ad9\u68ee\u4e25\u7684\u201c\u76fe\u724c\u201d\uff08\u53cd\u722c\u866b\u7cfb\u7edf\uff09\u65f6\uff0c\u4e5f\u9700\u8981\u5177\u5907\u5f3a\u5927\u7684\u201c\u97e7\u6027\u201d\uff0c\u624d\u80fd\u907f\u514d\u201c\u4e00\u6298\u5c31\u65ad\u201d\u3002\u722c\u866b\u7684\u201c\u97e7\u6027\u201d\uff0c\u4f53\u73b0\u5728\u5b83\u9762\u5bf9IP\u88ab\u5c01\uff08Bans\uff09\u3001\u8bf7\u6c42\u8d85\u65f6\uff08Retries\uff09\u548c\u9a8c\u8bc1\u7801\uff08CAPTCHAs\uff09\u7b49\u632b\u6298\u65f6\uff0c\u4f18\u96c5\u7684\u5e94\u5bf9\u548c\u6062\u590d\u80fd\u529b\u3002\u672c\u6587\u5c06\u4ece\u67b6\u6784\u8bbe\u8ba1\u7684\u89d2\u5ea6\uff0c\u63a2\u8ba8\u5982\u4f55\u4e3a\u4f60\u7684Scrapy\u722c\u866b\uff0c\u6ce8\u5165\u8fd9\u79cd\u201c\u6253\u4e0d\u6b7b\u201d\u7684\u97e7\u6027\u3002<\/p>\n\n\n\n<p><strong>\u4e00\u3001\u201c\u97e7\u6027\u201d\u7684\u57fa\u77f3\uff1a\u4e00\u4e2a\u9ad8\u8d28\u91cf\u7684\u4ee3\u7406IP\u6c60<\/strong><\/p>\n\n\n\n<p>\u6240\u6709\u7b56\u7565\u90fd\u5efa\u7acb\u5728\u4e00\u4e2a\u524d\u63d0\u4e0a\uff1a\u4f60\u6709\u8db3\u591f\u591a\u7684\u3001\u9ad8\u8d28\u91cf\u7684\u201c\u5907\u7528\u8def\u7ebf\u201d\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u9009\u62e9<\/strong>\uff1a\u4e3a\u4f60\u7684Scrapy\u9879\u76ee\uff0c\u914d\u5907\u4e00\u4e2a\u50cf<strong>YiLu Proxy\u6613\u8def\u4ee3\u7406<\/strong>\u8fd9\u6837\uff0c<strong>\u62e5\u67099000\u4e07+\u52a8\u6001\u4f4f\u5b85IP<\/strong>\u7684\u5e9e\u5927IP\u6c60\u3002\u4f4f\u5b85IP\u7684\u9ad8\u4fe1\u8a89\u5ea6\uff0c\u80fd\u4ece\u6e90\u5934\u4e0a\u5927\u5e45\u51cf\u5c11\u88abBans\u548c\u89e6\u53d1CAPTCHAs\u7684\u6982\u7387\u3002\u8fd9\u662f\u6784\u5efa\u201c\u97e7\u6027\u201d\u7684\u7b2c\u4e00\u6b65\uff0c\u4e5f\u662f\u6700\u91cd\u8981\u7684\u4e00\u6b65\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u4e8c\u3001\u201c\u97e7\u6027\u201d\u7684\u4f53\u73b0\u4e00\uff1a\u4f18\u96c5\u5730\u5904\u7406IP\u88ab\u5c01\uff08Bans\uff09<\/strong><\/p>\n\n\n\n<p>\u5f53\u4e00\u4e2a\u4ee3\u7406IP\u88ab\u76ee\u6807\u7f51\u7ad9\u5c01\u7981\u65f6\uff0c\u4f60\u7684\u722c\u866b\u4e0d\u5e94\u5d29\u6e83\uff0c\u800c\u5e94\u201c\u5904\u53d8\u4e0d\u60ca\u201d\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7b56\u7565\u6838\u5fc3<\/strong>\uff1a<strong>\u81ea\u5b9a\u4e49\u4e0b\u8f7d\u4e2d\u95f4\u4ef6\uff08Downloader Middleware\uff09<\/strong><\/li>\n\n\n\n<li><strong>\u67b6\u6784\u601d\u8def<\/strong>\uff1a\n<ol start=\"1\" class=\"wp-block-list\">\n<li>\u5728\u4e2d\u95f4\u4ef6\u7684<code>process_response<\/code>\u65b9\u6cd5\u4e2d\uff0c\u68c0\u67e5\u8fd4\u56de\u7684<code>response<\/code>\u7684\u72b6\u6001\u7801\u3002\u5982\u679c\u72b6\u6001\u7801\u662f<code>403<\/code>\uff08\u7981\u6b62\u8bbf\u95ee\uff09\u3001<code>410<\/code>\uff08\u5df2\u79fb\u9664\uff09\u6216\u4f60\u6839\u636e\u7ecf\u9a8c\u5224\u65ad\u4e3aIP\u88ab\u5c01\u7684\u5176\u4ed6\u72b6\u6001\u7801\uff0c\u5c31\u8ba4\u4e3a\u5f53\u524d\u4ee3\u7406IP\u5df2\u201c\u9635\u4ea1\u201d\u3002<\/li>\n\n\n\n<li>\u6b64\u65f6\uff0c\u4e0d\u8981\u76f4\u63a5\u629b\u5f03\u8fd9\u4e2a\u8bf7\u6c42\u3002\u800c\u662f\u5c06\u5f53\u524d\u4f7f\u7528\u7684\u4ee3\u7406IP\uff08\u53ef\u4ee5\u4ece<code>request.meta['proxy']<\/code>\u4e2d\u83b7\u53d6\uff09\u6807\u8bb0\u4e3a\u201c\u5bf9\u8be5\u7f51\u7ad9\u65e0\u6548\u201d\u3002<\/li>\n\n\n\n<li>\u7136\u540e\uff0c\u4e3a\u8fd9\u4e2a<code>request<\/code>\u5bf9\u8c61\uff0c\u91cd\u65b0\u4ece\u4f60\u7684\u4ee3\u7406\u6c60\u4e2d\u83b7\u53d6\u4e00\u4e2a<strong>\u65b0\u7684\u4ee3\u7406IP<\/strong>\uff0c\u5e76\u8fd4\u56de\u8fd9\u4e2a<strong>\u65b0\u7684\u8bf7\u6c42\u5bf9\u8c61<\/strong>\u7ed9Scrapy\u5f15\u64ce\u3002Scrapy\u4f1a\u7528\u65b0\u7684IP\uff0c\u5bf9\u5931\u8d25\u7684URL\u8fdb\u884c<strong>\u81ea\u52a8\u91cd\u8bd5<\/strong>\u3002<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>\u4e09\u3001\u201c\u97e7\u6027\u201d\u7684\u4f53\u73b0\u4e8c\uff1a\u667a\u80fd\u5730\u5904\u7406\u8d85\u65f6\u4e0e\u91cd\u8bd5\uff08Retries\uff09<\/strong><\/p>\n\n\n\n<p>\u7f51\u7edc\u6ce2\u52a8\u662f\u5e38\u6001\uff0cScrapy\u81ea\u5e26\u4e86\u91cd\u8bd5\u4e2d\u95f4\u4ef6\uff0c\u4f46\u6211\u4eec\u53ef\u4ee5\u8ba9\u5b83\u66f4\u667a\u80fd\u3002<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" src=\"http:\/\/www.yilus5.com\/blog\/wp-content\/uploads\/image-2025-04-25T092803.768.jpg\" alt=\"\"\/><\/figure>\n<\/div>\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7b56\u7565\u6838\u5fc3<\/strong>\uff1a<strong>\u7ed3\u5408\u91cd\u8bd5\u4e2d\u95f4\u4ef6\u4e0e\u81ea\u5b9a\u4e49\u4ee3\u7406\u903b\u8f91<\/strong><\/li>\n\n\n\n<li><strong>\u67b6\u6784\u601d\u8def<\/strong>\uff1a\n<ol start=\"1\" class=\"wp-block-list\">\n<li>\u5728<code>settings.py<\/code>\u4e2d\uff0c\u5f00\u542fScrapy\u7684\u91cd\u8bd5\u4e2d\u95f4\u4ef6 (<code>RetryMiddleware<\/code>)\uff0c\u5e76\u8bbe\u7f6e\u5408\u7406\u7684<code>RETRY_TIMES<\/code>\uff08\u4f8b\u59823\u6b21\uff09\u3002<\/li>\n\n\n\n<li>\u5728\u4f60\u7684\u81ea\u5b9a\u4e49\u4ee3\u7406\u4e2d\u95f4\u4ef6\u7684<code>process_exception<\/code>\u65b9\u6cd5\u4e2d\uff0c\u6355\u83b7<code>twisted.internet.error.TimeoutError<\/code>\u7b49\u8d85\u65f6\u5f02\u5e38\u3002<\/li>\n\n\n\n<li>\u5f53\u6355\u83b7\u5230\u5f02\u5e38\u65f6\uff0c\u4f60\u540c\u6837\u53ef\u4ee5\u6267\u884c\u201c\u66f4\u6362\u4ee3\u7406\u5e76\u91cd\u65b0\u8bf7\u6c42\u201d\u7684\u903b\u8f91\u3002\u8fd9\u6837\u505a\u7684\u597d\u5904\u662f\uff0cScrapy\u7684\u6bcf\u4e00\u6b21\u5b98\u65b9\u91cd\u8bd5\uff0c\u90fd\u4f1a\u901a\u8fc7\u4f60\u7684\u4e2d\u95f4\u4ef6\uff0c\u4f7f\u7528\u4e00\u4e2a\u5168\u65b0\u7684\u4ee3\u7406IP\uff0c\u800c\u4e0d\u662f\u7528\u540c\u4e00\u4e2a\u5931\u6548\u7684IP\u53cd\u590d\u649e\u5899\uff0c\u6781\u5927\u5730\u63d0\u9ad8\u4e86\u91cd\u8bd5\u7684\u6210\u529f\u7387\u3002<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>\u56db\u3001\u201c\u97e7\u6027\u201d\u7684\u4f53\u73b0\u4e09\uff1a\u5e94\u5bf9\u9a8c\u8bc1\u7801\uff08CAPTCHAs\uff09\u7684\u6311\u6218<\/strong><\/p>\n\n\n\n<p>\u8fd9\u662f\u6700\u9ad8\u7ea7\u7684\u201c\u97e7\u6027\u201d\u8003\u9a8c\u3002<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u7b56\u7565\u6838\u5fc3<\/strong>\uff1a<strong>\u8bc6\u522bCAPTCHA\u5e76\u96c6\u6210\u7b2c\u4e09\u65b9\u670d\u52a1<\/strong><\/li>\n\n\n\n<li><strong>\u67b6\u6784\u601d\u8def<\/strong>\uff1a\n<ol start=\"1\" class=\"wp-block-list\">\n<li><strong>\u8bc6\u522b<\/strong>\uff1a\u5728<code>process_response<\/code>\u65b9\u6cd5\u4e2d\uff0c\u901a\u8fc7\u68c0\u67e5\u9875\u9762\u5185\u5bb9\u662f\u5426\u5305\u542b\u201cCAPTCHA\u201d\u3001\u201c\u9a8c\u8bc1\u7801\u201d\u3001\u201c\u4eba\u673a\u9a8c\u8bc1\u201d\u7b49\u5173\u952e\u8bcd\uff0c\u6216\u7279\u5b9a\u7684HTML\u5143\u7d20\uff0c\u6765\u5224\u65ad\u662f\u5426\u9047\u5230\u4e86\u9a8c\u8bc1\u7801\u3002<\/li>\n\n\n\n<li><strong>\u96c6\u6210<\/strong>\uff1a\u4e00\u65e6\u8bc6\u522b\u51fa\u9a8c\u8bc1\u7801\uff0c\u722c\u866b\u6682\u505c\u5bf9\u8be5\u9875\u9762\u7684\u76f4\u63a5\u8bf7\u6c42\u3002\u5b83\u4f1a\u5c06\u9a8c\u8bc1\u7801\u7684\u56fe\u7247\u3001\u7f51\u7ad9\u7684<code>site-key<\/code>\u7b49\u4fe1\u606f\uff0c\u901a\u8fc7API\uff0c\u53d1\u9001\u7ed9\u4e00\u4e2a\u4e13\u4e1a\u7684\u7b2c\u4e09\u65b9\u201c\u6253\u7801\u5e73\u53f0\u201d\uff08CAPTCHA Solving Service\uff09\u3002<\/li>\n\n\n\n<li><strong>\u63d0\u4ea4\u4e0e\u6062\u590d<\/strong>\uff1a\u6253\u7801\u5e73\u53f0\u8fd4\u56de\u8bc6\u522b\u7ed3\u679c\u540e\uff0c\u4f60\u7684\u722c\u866b\u518d\u5c06\u7ed3\u679c\u63d0\u4ea4\u7ed9\u7f51\u7ad9\uff0c\u901a\u8fc7\u9a8c\u8bc1\u540e\uff0c\u7ee7\u7eed\u6267\u884c\u540e\u7eed\u7684\u6293\u53d6\u4efb\u52a1\u3002\u5728\u6574\u4e2a\u9a8c\u8bc1\u8fc7\u7a0b\u4e2d\uff0c\u6700\u597d\u4f7f\u7528\u201c\u7c98\u6027\u4f1a\u8bdd\u201d\u7684\u4ee3\u7406\uff0c\u4ee5\u4fdd\u6301IP\u7684\u7a33\u5b9a\u3002<\/li>\n<\/ol>\n<\/li>\n<\/ul>\n\n\n\n<p><strong>YiLu Proxy\u5982\u4f55\u8d4b\u80fd\u201c\u97e7\u6027\u201d\uff1f<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>\u63d0\u4f9b\u5145\u8db3\u7684\u201c\u5907\u7528\u8def\u7ebf\u201d<\/strong>\uff1aYiLu Proxy\u7684\u6d77\u91cf\u4f4f\u5b85IP\uff0c\u786e\u4fdd\u4e86\u4f60\u7684\u722c\u866b\u5728\u4efb\u4f55\u65f6\u5019\uff0c\u90fd\u6709\u8db3\u591f\u591a\u7684\u65b0IP\u53ef\u4f9b\u5207\u6362\u548c\u91cd\u8bd5\u3002<\/li>\n\n\n\n<li><strong>\u652f\u6301\u590d\u6742\u7684\u4f1a\u8bdd\u7b56\u7565<\/strong>\uff1a\u4ed6\u4eec<strong>\u63d0\u4f9b\u9ad8\u901f\u8fde\u63a5\u3001\u5b89\u5168\u533f\u540d\u7684\u72ec\u4eabS5\u4ee3\u7406\u548cHTTP\u534f\u8bae\u670d\u52a1<\/strong>\uff0c\u5e76\u652f\u6301\u7075\u6d3b\u7684\u4f1a\u8bdd\u7ba1\u7406\u3002\u8fd9\u4f7f\u5f97\u5728\u5904\u7406CAPTCHA\u6216\u591a\u6b65\u767b\u5f55\u9a8c\u8bc1\u65f6\uff0c\u4f60\u80fd\u83b7\u5f97\u6240\u9700\u7684\u201c\u7c98\u6027IP\u201d\uff0c\u4ee5\u4fdd\u8bc1\u64cd\u4f5c\u7684\u8fde\u8d2f\u6027\u3002<\/li>\n\n\n\n<li><strong>\u9ad8\u6210\u529f\u7387\u51cf\u8f7b\u201c\u97e7\u6027\u201d\u8d1f\u62c5<\/strong>\uff1a\u7531\u4e8e\u5176IP\u8d28\u91cf\u9ad8\uff0c\u4ece\u6e90\u5934\u4e0a\u5c31\u51cf\u5c11\u4e86\u88ab\u5c01\u548c\u9047\u5230\u9a8c\u8bc1\u7801\u7684\u6982\u7387\uff0c\u8ba9\u4f60\u7684\u722c\u866b\u80fd\u66f4\u4e13\u6ce8\u4e8e\u6570\u636e\u6293\u53d6\u672c\u8eab\u3002<\/li>\n<\/ul>\n\n\n\n<p><strong>\u7ed3\u8bed<\/strong>\uff1a\u4e00\u4e2a\u771f\u6b63\u5f3a\u5927\u7684Scrapy\u722c\u866b\uff0c\u5176\u6838\u5fc3\u7ade\u4e89\u529b\u4e0d\u4ec5\u5728\u4e8e\u901f\u5ea6\uff0c\u66f4\u5728\u4e8e\u9762\u5bf9\u632b\u6298\u65f6\u7684\u201c\u97e7\u6027\u201d\u3002\u901a\u8fc7\u5728\u4e2d\u95f4\u4ef6\u4e2d\uff0c\u4f18\u96c5\u5730\u96c6\u6210\u5bf9Bans\u3001Retries\u548cCAPTCHAs\u7684\u5904\u7406\u903b\u8f91\uff0c\u5e76\u4f9d\u6258\u4e8e\u4e00\u4e2a\u50cfYiLu Proxy\u4e00\u6837\u8d44\u6e90\u96c4\u539a\u3001\u529f\u80fd\u5f3a\u5927\u7684\u4ee3\u7406IP\u6c60\uff0c\u4f60\u7684\u722c\u866b\u5c06\u4e0d\u518d\u662f\u8106\u5f31\u7684\u201c\u4e00\u6b21\u6027\u201d\u811a\u672c\uff0c\u800c\u662f\u4e00\u4e2a\u80fd\u5728\u590d\u6742\u7f51\u7edc\u73af\u5883\u4e2d\uff0c\u575a\u97e7\u4e0d\u62d4\u3001\u4f7f\u547d\u5fc5\u8fbe\u7684\u201c\u6570\u636e\u5de5\u5175\u201d\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Scrapy\u4ee5\u5176\u5f3a\u5927\u7684\u5f02\u6b65\u6027\u80fd\uff0c\u6210\u4e3aPython\u722c\u866b\u9886\u57df\u7684\u5229\u5668\u3002\u7136\u800c\uff0c\u518d\u5feb\u7684\u201c\u5229\u5251\u201d\uff0c\u5728\u9762\u5bf9\u73b0\u4ee3\u7f51\u7ad9\u68ee\u4e25\u7684\u201c\u76fe &#8230; <a title=\"Scrapy\u722c\u866b\u4ee3\u7406\u7684\u201c\u97e7\u6027\u201d\u4e4b\u9053\uff1a\u5982\u4f55\u4f18\u96c5\u5904\u7406Bans\u3001Retries\u4e0eCAPTCHAs\uff1f\" class=\"read-more\" href=\"https:\/\/www.yilus5.com\/blog\/2872.html\" aria-label=\"\u9605\u8bfb Scrapy\u722c\u866b\u4ee3\u7406\u7684\u201c\u97e7\u6027\u201d\u4e4b\u9053\uff1a\u5982\u4f55\u4f18\u96c5\u5904\u7406Bans\u3001Retries\u4e0eCAPTCHAs\uff1f\">\u9605\u8bfb\u66f4\u591a<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-2872","post","type-post","status-publish","format-standard","hentry","category-yiluproxy5"],"_links":{"self":[{"href":"https:\/\/www.yilus5.com\/blog\/wp-json\/wp\/v2\/posts\/2872","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.yilus5.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.yilus5.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.yilus5.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.yilus5.com\/blog\/wp-json\/wp\/v2\/comments?post=2872"}],"version-history":[{"count":1,"href":"https:\/\/www.yilus5.com\/blog\/wp-json\/wp\/v2\/posts\/2872\/revisions"}],"predecessor-version":[{"id":2883,"href":"https:\/\/www.yilus5.com\/blog\/wp-json\/wp\/v2\/posts\/2872\/revisions\/2883"}],"wp:attachment":[{"href":"https:\/\/www.yilus5.com\/blog\/wp-json\/wp\/v2\/media?parent=2872"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.yilus5.com\/blog\/wp-json\/wp\/v2\/categories?post=2872"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.yilus5.com\/blog\/wp-json\/wp\/v2\/tags?post=2872"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}