{"id":1201,"date":"2024-11-21T19:14:33","date_gmt":"2024-11-21T11:14:33","guid":{"rendered":"https:\/\/gemmartdesign.com\/?p=1201"},"modified":"2024-11-30T00:36:06","modified_gmt":"2024-11-29T16:36:06","slug":"python-post15","status":"publish","type":"post","link":"https:\/\/gemmartdesign.com\/?p=1201","title":{"rendered":"Python\u554f\u984c\u7d00\u9304#15-\u6293\u53d6AJAX\u7db2\u7ad9\u8cc7\u6599 medium\u7db2\u7ad9\u6a19\u984c\u7bc4\u4f8b"},"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\">\u76ee\u6a19<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6293\u53d6Medium\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-post15-3.png\" alt=\"\" class=\"wp-image-1269\" srcset=\"https:\/\/gemmartdesign.com\/wp-content\/uploads\/2024\/11\/python-post15-3.png 800w, https:\/\/gemmartdesign.com\/wp-content\/uploads\/2024\/11\/python-post15-3-300x161.png 300w, https:\/\/gemmartdesign.com\/wp-content\/uploads\/2024\/11\/python-post15-3-768x412.png 768w, https:\/\/gemmartdesign.com\/wp-content\/uploads\/2024\/11\/python-post15-3-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\">\u767c\u9001\u8acb\u6c42\u53d6\u5f97\u7db2\u7ad9\u6587\u5b57\u8cc7\u6599<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f1:  \u78ba\u8a8dMedium\u7db2\u7ad9\u6709Payload\uff0c\u4e14Headers\u6709Content-Type\u53c3\u6578\uff0c\u9700\u52a0\u5165\u8acb\u6c42\u4ee3\u78bc<\/p>\n\n\n\n<figure class=\"wp-block-gallery has-nested-images columns-2 wp-block-gallery-1 is-layout-flex wp-block-gallery-is-layout-flex\">\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"762\" height=\"429\" data-id=\"1253\" src=\"https:\/\/gemmartdesign.com\/wp-content\/uploads\/2024\/11\/python-post15-1.png\" alt=\"\" class=\"wp-image-1253\" srcset=\"https:\/\/gemmartdesign.com\/wp-content\/uploads\/2024\/11\/python-post15-1.png 762w, https:\/\/gemmartdesign.com\/wp-content\/uploads\/2024\/11\/python-post15-1-300x169.png 300w, https:\/\/gemmartdesign.com\/wp-content\/uploads\/2024\/11\/python-post15-1-585x329.png 585w\" sizes=\"(max-width: 762px) 100vw, 762px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" width=\"762\" height=\"429\" data-id=\"1254\" src=\"https:\/\/gemmartdesign.com\/wp-content\/uploads\/2024\/11\/python-post15-2.png\" alt=\"\" class=\"wp-image-1254\" srcset=\"https:\/\/gemmartdesign.com\/wp-content\/uploads\/2024\/11\/python-post15-2.png 762w, https:\/\/gemmartdesign.com\/wp-content\/uploads\/2024\/11\/python-post15-2-300x169.png 300w, https:\/\/gemmartdesign.com\/wp-content\/uploads\/2024\/11\/python-post15-2-585x329.png 585w\" sizes=\"(max-width: 762px) 100vw, 762px\" \/><\/figure>\n<\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f2:# \u66f4\u6539limit\u5f8c\u9762\u6578\u5b57\u53ef\u4ee5\u8dd1\u51fa\u6700\u591a20\u7bc7<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>import urllib.request as req\nimport json\nurl=\"https:\/\/medium.com\/_\/graphql\"\nrequestData={\"operationName\"\u6b64\u8655\u8907\u88fd\u5b8c\u6574Payload\u4ee3\u78bc\"}\nrequest=req.Request(url,headers={\n    \"content-type\":\"application\/json; charset=utf-8\",\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    },data=json.dumps(requestData).encode(\"utf-8\"))\nwith req.urlopen(request) as response:\n    result=response.read().decode(\"utf-8\")\n\nprint(result)\n<\/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<h4 class=\"wp-block-heading\">\u89e3\u6790json\u8cc7\u6599\uff0c\u6293\u53d6\u6587\u7ae0\u6a19\u984c\uff0c\u78ba\u5b9a\u53ef\u4ee5\u5370\u51fa\u7b2c\u4e00\u7bc7\u6587\u7ae0<\/h4>\n\n\n\n<p class=\"wp-block-paragraph\">\u6ce8\u610f: 0\u4e0d\u9700\u8981\u52a0\u4e0a\u5f15\u865f&#8221;0&#8243;<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>result=json.loads(result)\nprint(result&#91;\"data\"]&#91;\"webRecommendedFeed\"]&#91;\"items\"]&#91;0]&#91;\"post\"]&#91;\"title\"]) <\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>The Web We Have to Save<\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">\u4f7f\u7528\u8ff4\u5708\u6293\u53d620\u7bc7\u6587\u6587\u7ae0\u6a19\u984c<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>result=json.loads(result)\nitems=result&#91;\"data\"]&#91;\"webRecommendedFeed\"]&#91;\"items\"]\nfor item in items:\n    print(item&#91;\"post\"]&#91;\"title\"])<\/code><\/pre>\n\n\n\n<div style=\"height:30px\" aria-hidden=\"true\" class=\"wp-block-spacer\"><\/div>\n\n\n\n<h4 class=\"wp-block-heading\">Output<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code>How Reading Can Literally Change Your Brain Chemistry\n31 Photos From September 11th That You Have Never Seen\nMost People Don\u2019t Know the Difference Between \u201cFeelings\u201d and \u201cEmotions\u201d\nThe Crossroads of Should and Must\nSystem Design Blueprint: The Ultimate Guide\nLate Loves Are Better Loves\nHow \u2018Should\u2019 Makes Us Stupid\u200a\u2014\u200aAnd How to Get Smart Again\nYour portfolios are fucking boring\nHow To Write With AI Without Sounding Like AI\u200a\u2014\u200aChatGPT Canvas\n9 Strategies I Used To Get 237,000 Website Visits From Google Discover\nThe Insanity of Relying on Vector Embeddings: Why RAG Fails\nGenAI with Python: Build Agents from Scratch (Complete Tutorial)\nYou\u2019re Using ChatGPT Wrong! Here\u2019s How to Be Ahead of 99% of ChatGPT Users\nSmoking Too Much Weed Almost Ruined My Life\nWhy can\u2019t we read anymore?\nForget LangChain, CrewAI and AutoGen\u200a\u2014\u200aTry This Framework and Never Look Back\nHow to Think About Your Career\nThe UX job market REALLY sucks right now\nI\u2019m Now Terrified of AI, And You Should Be Too\nIt\u2019s Not Our Place To Change Them.<\/code><\/pre>\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":1255,"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-1201","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\/1201","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=1201"}],"version-history":[{"count":5,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=\/wp\/v2\/posts\/1201\/revisions"}],"predecessor-version":[{"id":1271,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=\/wp\/v2\/posts\/1201\/revisions\/1271"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=\/wp\/v2\/media\/1255"}],"wp:attachment":[{"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1201"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1201"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/gemmartdesign.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1201"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}