{"id":1199,"date":"2024-11-20T19:14:33","date_gmt":"2024-11-20T11:14:33","guid":{"rendered":"https:\/\/gemmartdesign.com\/?p=1199"},"modified":"2024-11-30T00:30:10","modified_gmt":"2024-11-29T16:30:10","slug":"python-post14","status":"publish","type":"post","link":"https:\/\/gemmartdesign.com\/?p=1199","title":{"rendered":"Python\u554f\u984c\u7d00\u9304#14-\u6293\u53d6KKDAY\u7db2\u7ad9\u8cc7\u6599\u9047\u5230SSI\u6191\u8b49\u554f\u984c"},"content":{"rendered":"\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-6f3c296329a310c4ec4b8858acb7fc91\" style=\"color:#ff8a65\">\u672c\u5468\u76ee\u6a19<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">\u5b78\u7fd2WebCrawler\u57fa\u672c\u7528\u6cd5\u8207\u61c9\u7528<\/p>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-d378f6d1ee3ff41f6cf438efcd397311\" style=\"color:#ff8a65\">\u4efb\u52d9<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>\u5982\u4f55\u8a2a\u554f\u7db2\u7ad9\u52a0\u5165\u700f\u89bd\u5668\u8cc7\u8a0a\u4e26\u53d6\u5f97\u7db2\u7ad9\u8cc7\u6599<\/li>\n\n\n\n<li>\u4f7f\u7528Beautifulsoup\u6293\u53d6\u7db2\u7ad9\u6a19\u984c<\/li>\n\n\n\n<li>\u52a0\u5165cookie\u8a9e\u6cd5<\/li>\n\n\n\n<li>\u4f7f\u7528\u8ff4\u5708\u6293\u53d6\u591a\u9801\u8cc7\u6599<\/li>\n\n\n\n<li>\u7df4\u7fd2AJAX\u7db2\u9801-KKDAY<\/li>\n\n\n\n<li>\u7df4\u7fd2AJAX\u7db2\u9801-Medium<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading has-text-color has-link-color wp-elements-4ff4e1ba3503f9246295601b9b47d959\" style=\"color:#ff8a65\">\u5c08\u6848\u7df4\u7fd2<\/h2>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color wp-elements-46a507c401b8fd3679821363ba9f5380\" style=\"color:#4b4b4b\">\u76ee\u6a19<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6293\u53d6KKDAY\u9996\u9801\u6a19\u984c<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img fetchpriority=\"high\" decoding=\"async\" width=\"800\" height=\"429\" src=\"https:\/\/gemmartdesign.com\/wp-content\/uploads\/2024\/11\/python-post13-1-1.png\" alt=\"\" class=\"wp-image-1266\" srcset=\"https:\/\/gemmartdesign.com\/wp-content\/uploads\/2024\/11\/python-post13-1-1.png 800w, https:\/\/gemmartdesign.com\/wp-content\/uploads\/2024\/11\/python-post13-1-1-300x161.png 300w, https:\/\/gemmartdesign.com\/wp-content\/uploads\/2024\/11\/python-post13-1-1-768x412.png 768w, https:\/\/gemmartdesign.com\/wp-content\/uploads\/2024\/11\/python-post13-1-1-585x314.png 585w\" sizes=\"(max-width: 800px) 100vw, 800px\" \/><\/figure>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color wp-elements-29f3fb0955b734448d525246e9f2dd8f\" style=\"color:#4b4b4b\">\u767c\u9001\u8acb\u6c42\u53d6\u5f97\u7db2\u7ad9\u6587\u5b57\u8cc7\u6599<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>import urllib.request as req\nurl=\"https:\/\/www.kkday.com\/zh-tw\/home\/ajax_get_homepage_setting?csrf_token_name=0e2694a80a182eaccdfe363b65da5ecb\"\nrequest=req.Request(url, headers={\n    \"cookie\":\"_ga_RJJY5WQFKP=GS1.1.1732118298.1.1.1732118539.60.0.0\",\n    \"user-agent\":\"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/130.0.0.0 Safari\/537.36\"\n})\nwith req.urlopen(request) as response:\n    info=response.read().decode(\"utf-8\")\nprint(info)<\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color wp-elements-7159d877fd7628796d4c760403cc4d2e\" style=\"color:#4b4b4b\">\u51fa\u73fe\u932f\u8aa4<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">urllib.error.URLError: &lt;urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: Missing Subject Key Identifier (_ssl.c:1020)&gt;<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">\u51fa\u73feSSL\u9a57\u8b49\u554f\u984c\uff0c\u7db2\u8def\u641c\u5c0b\u53c3\u8003<a href=\"https:\/\/medium.com\/@trendy81502\/python%E7%88%AC%E8%9F%B2%E8%B7%B3%E5%87%BAssl-certificate%E5%95%8F%E9%A1%8C%E7%AD%86%E8%A8%98-93c424e46e26\">\u9019\u7bc7<\/a>\uff0c\u4fee\u6539\u7a0b\u5f0f\u78bc\u70ba<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import ssl\nimport urllib.request as req\nssl._create_default_https_context = ssl._create_unverified_context\nurl=\"https:\/\/www.kkday.com\/zh-tw\/home\/ajax_get_homepage_setting?csrf_token_name=0e2694a80a182eaccdfe363b65da5ecb\"\nrequest=req.Request(url, headers={\n    \"cookie\":\"_ga_RJJY5WQFKP=GS1.1.1732118298.1.1.1732118539.60.0.0\",\n    \"user-agent\":\"Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/130.0.0.0 Safari\/537.36\"\n})\nwith req.urlopen(request) as response:\n    info=response.read().decode(\"utf-8\")\nprint(info)<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">\u53ef\u6210\u529f\u5370\u51fa\u8cc7\u6599\uff0c\u6700\u5f8c\u4e00\u884c\u53ef\u4ee5\u8a3b\u89e3\u6389<\/p>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color wp-elements-e4a0488b554479ea9271358ef94270cf\" style=\"color:#4b4b4b\">\u89e3\u6790json\u8cc7\u6599\uff0c\u6293\u53d6\u6587\u7ae0\u6a19\u984c<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>import json\ninfo=json.loads(info)\nposts=info&#91;\"data\"]&#91;\"top_products\"]&#91;\"prod_list\"]\nfor post in posts:\n    print(post&#91;\"name\"])<\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h3 class=\"wp-block-heading has-text-color has-link-color wp-elements-2f2a1e4c54292d331012a993eb8575ca\" style=\"color:#4b4b4b\">Output<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>SHIBUYA SKY \u5c55\u671b\u53f0\u96fb\u5b50\u9580\u7968|\u5373\u8cb7\u5373\u7528\n\u6771\u4eac\u8fea\u58eb\u5c3c\u5ea6\u5047\u5340\u9580\u7968 Tokyo Disney Resort\n\u53f0\u5317\u5c55\u89bd|\u8349\u9593\u5f4c\u751f\u7684\u300c\u8ecc\u8de1\u300d\u8207\u300c\u5947\u8de1\u300d\u2014\u2014W Collection &amp; More 1951-2005\n\u3010\u65b0\u52a0\u5761\u51fa\u767c\u3011 \u8fea\u58eb\u5c3c\u90f5\u8f2a | \u8fea\u58eb\u5c3c\u63a2\u96aa\u865f(Disney Adventure)|3\u30014 \u665a\u884c\u7a0b\n\u6771\u4eac\u5730\u9435\u4e00\u65e5\u5238\/\u4e8c\u65e5\u5238\/\u4e09\u65e5\u5238|Tokyo Subway Ticket\n\u97d3\u570b\u91dc\u5c71\u901a\u884c\u8b49 VISIT BUSAN PASS\n\u5927\u962a\u5468\u904a\u5361\u4e00\u65e5\u5238\u30fb\u4e8c\u65e5\u5238 OSAKA AMAZING PASS \u96fb\u5b50\u7968\n\u6771\u4eac\u4ea4\u901a\u5957\u7968|\u4eac\u6210\u96fb\u9435 Skyliner \u8eca\u7968+\u6771\u4eac\u5730\u9435 24 \/ 48 \/ 72 \u5c0f\u6642\u4e58\u8eca\u5238\n\u65e5\u672c\u74b0\u7403\u5f71\u57ce\u9580\u7968 Universal Studios Japan|\u65e5\u672c\u5927\u962a (\u5b98\u65b9\u6388\u6b0a)\n\u97d3\u570b\u91dc\u5c71|\u6d77\u96f2\u53f0\u85cd\u7dda\u516c\u5712\u6d77\u5cb8\u5217\u8eca\u30fb\u5929\u7a7a\u81a0\u56ca\u5217\u8eca\u7968<\/code><\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u672c\u5468\u76ee\u6a19 \u5b78\u7fd2WebCrawler\u57fa\u672c\u7528\u6cd5\u8207\u61c9\u7528 \u4efb\u52d9 \u5c08\u6848&hellip;<\/p>\n","protected":false},"author":1,"featured_media":1251,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"content-type":"","pagelayer_contact_templates":[],"_pagelayer_content":"","_lmt_disableupdate":"","_lmt_disable":"","footnotes":""},"categories":[9],"tags":[],"class_list":["post-1199","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-python"],"_links":{"self":[{"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=\/wp\/v2\/posts\/1199","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1199"}],"version-history":[{"count":8,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=\/wp\/v2\/posts\/1199\/revisions"}],"predecessor-version":[{"id":1267,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=\/wp\/v2\/posts\/1199\/revisions\/1267"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=\/wp\/v2\/media\/1251"}],"wp:attachment":[{"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1199"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1199"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1199"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}