{"id":2585,"date":"2020-12-15T13:01:06","date_gmt":"2020-12-15T05:01:06","guid":{"rendered":"http:\/\/blog.ywdevops.cn\/?p=2585"},"modified":"2022-12-01T09:57:53","modified_gmt":"2022-12-01T01:57:53","slug":"python-10","status":"publish","type":"post","link":"https:\/\/blog.ywdevops.cn\/index.php\/2020\/12\/15\/python-10\/","title":{"rendered":"python\u4e4b\u7f51\u7edc\u722c\u866b"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">\u4e00\u3001\u7f51\u7edc\u722c\u866b\u7684\u57fa\u672c\u539f\u7406\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u7f51\u7edc\u722c\u866b\u7684\u57fa\u672c\u5de5\u4f5c\u6d41\u7a0b\u5982\u4e0b\uff1a<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>\u83b7\u53d6\u521d\u59cb\u7684URL\uff0c\u6b64URL\u5730\u5740\u662f\u7528\u6237\u81ea\u5df1\u8bbe\u5b9a\u7684\u521d\u59cb\u722c\u53d6\u7684\u7f51\u9875<\/li><li>\u722c\u53d6\u5bf9\u5e94\u7684URL\u5730\u5740\u7f51\u9875\u65f6\uff0c\u83b7\u53d6\u65b0\u7684URL\u5730\u5740<\/li><li>\u5c06\u65b0\u7684URL\u5730\u5740\u653e\u5165\u5230URL\u961f\u5217\u4e2d<\/li><li>\u4eceURL\u961f\u5217\u4e2d\u8bfb\u53d6\u65b0\u7684URL\uff0c\u4f9d\u636e\u65b0\u7684URL\u722c\u53d6\u7f51\u9875\uff0c\u540c\u65f6\u4ece\u65b0\u7684\u7f51\u9875\u4e2d\u83b7\u53d6\u65b0\u7684URL\u5730\u5740\uff0c\u91cd\u590d\u4e0a\u8ff0\u7684\u722c\u53d6\u8fc7\u7a0b<\/li><li>\u8bbe\u7f6e\u505c\u6b62\u6761\u4ef6\uff0c\u5982\u679c\u6ca1\u6709\u8bbe\u7f6e\u505c\u6b62\u6761\u4ef6\uff0c\u722c\u866b\u4f1a\u4e00\u76f4\u722c\u4e0b\u53bb\uff0c\u76f4\u5230\u65e0\u6cd5\u83b7\u53d6\u65b0\u7684URL\u5730\u5740\u4e3a\u6b62\uff0c\u8bbe\u7f6e\u4e86\u505c\u6b62\u6761\u4ef6\u540e\uff0c\u722c\u91cd\u5c06\u4f1a\u5728\u6ee1\u8db3\u505c\u6b62\u6761\u4ef6\u65f6\u505c\u6b62\u722c\u53d6<\/li><\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e8c\u3001Python\u7684\u7f51\u7edc\u8bf7\u6c42\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u5728Python\u4e2d\u5b9e\u73b0HTTP\u7f51\u7edc\u8bf7\u6c42\u5e38\u89c1\u7684\u4e09\u79cd\u65b9\u5f0f\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">1\u3001urllib\u6a21\u5757\uff1a<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">urllib\u662fPython\u81ea\u5e26\u6a21\u5757\uff0c\u6b64\u6a21\u5757\u63d0\u4f9b\u4e86\u4e00\u4e2aurlopen()\u65b9\u6cd5\uff0c\u901a\u8fc7\u6b64\u65b9\u6cd5\u6307\u5b9aURL\u53d1\u9001\u7f51\u7edc\u8bf7\u6c42\u83b7\u53d6\u6570\u636e\uff0curllib\u63d0\u4f9b\u591a\u4e2a\u5b50\u6a21\u5757\uff0c\u5177\u4f53\u6a21\u5757\u540d\u4ee5\u53ca\u542b\u4e49\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"\"><tbody><tr><td class=\"has-text-align-center\" data-align=\"center\">\u6a21\u5757\u540d\u79f0<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u63cf\u8ff0<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">urllib.request<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u6b64\u6a21\u5757\u5b9a\u4e49\u4e86\u6253\u5f00URL(\u4e3b\u8981\u662fhttp)\u7684\u65b9\u6cd5\u548c\u7c7b<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">urllib.error<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u6b64\u6a21\u5757\u4e3b\u8981\u5305\u542b\u5f02\u5e38\u7c7b\uff0c\u57fa\u672c\u7684\u5f02\u5e38\u7c7b\u662fURLError<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">urllib.parse<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u6b64\u6a21\u5757\u5b9a\u4e49\u7684\u529f\u80fd\u5206\u4e3a\u4e24\u5927\u7c7b\uff0cURL\u89e3\u6790\u548cURL\u5f15\u7528<\/td><\/tr><tr><td class=\"has-text-align-center\" data-align=\"center\">urllib.robotparser<\/td><td class=\"has-text-align-center\" data-align=\"center\">\u6b64\u6a21\u5757\u7528\u4e8e\u89e3\u6790robots.txt\u6587\u4ef6<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4f8b\u5982\uff1a\u901a\u8fc7urllib.request\u6a21\u5757\u5b9e\u73b0\u53d1\u9001\u8bf7\u6c42\u5e76\u8bfb\u53d6\u7f51\u9875\u5185\u5bb9\u793a\u4f8b\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"502\" height=\"133\" src=\"http:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/12\/8.png\" alt=\"\" class=\"wp-image-2586\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/12\/8.png 502w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/12\/8-300x79.png 300w\" sizes=\"auto, (max-width: 502px) 100vw, 502px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u4e0a\u8ff0\u4ee3\u7801\u662f\u901a\u8fc7get\u8bf7\u6c42\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\uff0c\u4e0b\u9762\u901a\u8fc7Post\u8bf7\u6c42\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\u5982\u4e0b\uff1a<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"585\" height=\"146\" src=\"http:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/12\/30.png\" alt=\"\" class=\"wp-image-2588\" srcset=\"https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/12\/30.png 585w, https:\/\/blog.ywdevops.cn\/wp-content\/uploads\/2020\/12\/30-300x75.png 300w\" sizes=\"auto, (max-width: 585px) 100vw, 585px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>\u4e00\u3001\u7f51\u7edc\u722c\u866b\u7684\u57fa\u672c\u539f\u7406\uff1a \u7f51\u7edc\u722c\u866b\u7684\u57fa\u672c\u5de5\u4f5c\u6d41\u7a0b\u5982\u4e0b\uff1a \u83b7\u53d6\u521d\u59cb\u7684URL\uff0c\u6b64URL\u5730\u5740\u662f\u7528\u6237\u81ea\u5df1\u8bbe\u5b9a\u7684\u521d\u59cb\u722c\u53d6 [&hellip;]<\/p>\n","protected":false},"author":3,"featured_media":2589,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38,29],"tags":[],"class_list":["post-2585","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python","category-yunwei"],"blocksy_meta":{"styles_descriptor":{"styles":{"desktop":"","tablet":"","mobile":""},"google_fonts":[],"version":8}},"_links":{"self":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/2585","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/comments?post=2585"}],"version-history":[{"count":2,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/2585\/revisions"}],"predecessor-version":[{"id":2590,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/posts\/2585\/revisions\/2590"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media\/2589"}],"wp:attachment":[{"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/media?parent=2585"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/categories?post=2585"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.ywdevops.cn\/index.php\/wp-json\/wp\/v2\/tags?post=2585"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}