{"id":1171279,"date":"2025-01-15T16:33:24","date_gmt":"2025-01-15T08:33:24","guid":{"rendered":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1171279.html"},"modified":"2025-01-15T16:33:27","modified_gmt":"2025-01-15T08:33:27","slug":"python%e5%a6%82%e4%bd%95%e8%87%aa%e5%8a%a8%e7%88%ac%e5%8f%96%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/docs.pingcode.com\/ask\/ask-ask\/1171279.html","title":{"rendered":"python\u5982\u4f55\u81ea\u52a8\u722c\u53d6\u6570\u636e"},"content":{"rendered":"<p style=\"text-align:center;\" ><img decoding=\"async\" src=\"https:\/\/cdn-kb.worktile.com\/kb\/wp-content\/uploads\/2024\/04\/26073632\/19d61e93-bc8c-435c-917b-9330a25d1dc8.webp\" alt=\"python\u5982\u4f55\u81ea\u52a8\u722c\u53d6\u6570\u636e\" \/><\/p>\n<p><p> Python\u81ea\u52a8\u722c\u53d6\u6570\u636e\u7684\u65b9\u6cd5\u4e3b\u8981\u5305\u62ec<strong>\u4f7f\u7528requests\u5e93\u3001\u4f7f\u7528BeautifulSoup\u5e93\u3001\u4f7f\u7528Scrapy\u6846\u67b6<\/strong>\u3002\u5176\u4e2d\uff0crequests\u5e93\u53ef\u4ee5\u7528\u6765\u53d1\u9001HTTP\u8bf7\u6c42\uff0c\u83b7\u53d6\u7f51\u9875\u5185\u5bb9\uff1bBeautifulSoup\u5e93\u53ef\u4ee5\u7528\u6765\u89e3\u6790HTML\u548cXML\u6587\u6863\uff0c\u63d0\u53d6\u9700\u8981\u7684\u6570\u636e\uff1bScrapy\u6846\u67b6\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u722c\u866b\u6846\u67b6\uff0c\u9002\u7528\u4e8e\u590d\u6742\u7684\u722c\u53d6\u4efb\u52a1\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5982\u4f55\u4f7f\u7528\u8fd9\u4e09\u79cd\u65b9\u6cd5\u6765\u81ea\u52a8\u722c\u53d6\u6570\u636e\u3002<\/p>\n<\/p>\n<p><h2>\u4e00\u3001\u4f7f\u7528requests\u5e93<\/h2>\n<\/p>\n<p><h3>1\u3001\u53d1\u9001HTTP\u8bf7\u6c42<\/h3>\n<\/p>\n<p><p>Requests\u5e93\u662f\u4e00\u4e2a\u7b80\u5355\u6613\u7528\u7684HTTP\u5e93\uff0c\u53ef\u4ee5\u7528\u6765\u53d1\u9001HTTP\u8bf7\u6c42\u5e76\u83b7\u53d6\u54cd\u5e94\u3002\u8981\u4f7f\u7528requests\u5e93\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5\u5b83\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install requests<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u53d1\u9001\u4e00\u4e2aGET\u8bf7\u6c42\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>url = &#39;http:\/\/example.com&#39;<\/p>\n<p>response = requests.get(url)<\/p>\n<p>print(response.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u5904\u7406HTTP\u54cd\u5e94<\/h3>\n<\/p>\n<p><p>\u5728\u4e0a\u9762\u7684\u4ee3\u7801\u4e2d\uff0cresponse\u5bf9\u8c61\u5305\u542b\u4e86\u670d\u52a1\u5668\u7684\u54cd\u5e94\u3002\u4f60\u53ef\u4ee5\u901a\u8fc7\u4ee5\u4e0b\u5c5e\u6027\u548c\u65b9\u6cd5\u6765\u5904\u7406\u54cd\u5e94\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>response.status_code<\/strong>: \u83b7\u53d6HTTP\u72b6\u6001\u7801<\/li>\n<li><strong>response.text<\/strong>: \u83b7\u53d6\u54cd\u5e94\u5185\u5bb9\uff08\u5b57\u7b26\u4e32\u683c\u5f0f\uff09<\/li>\n<li><strong>response.content<\/strong>: \u83b7\u53d6\u54cd\u5e94\u5185\u5bb9\uff08\u4e8c\u8fdb\u5236\u683c\u5f0f\uff09<\/li>\n<li><strong>response.json()<\/strong>: \u5c06\u54cd\u5e94\u5185\u5bb9\u89e3\u6790\u4e3aJSON\u5bf9\u8c61<\/li>\n<\/ul>\n<p><p>\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">if response.status_code == 200:<\/p>\n<p>    data = response.json()<\/p>\n<p>    print(data)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u53d1\u9001POST\u8bf7\u6c42<\/h3>\n<\/p>\n<p><p>\u9664\u4e86GET\u8bf7\u6c42\uff0c\u4f60\u8fd8\u53ef\u4ee5\u53d1\u9001POST\u8bf7\u6c42\uff0c\u5e76\u4f20\u9012\u6570\u636e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">payload = {&#39;key1&#39;: &#39;value1&#39;, &#39;key2&#39;: &#39;value2&#39;}<\/p>\n<p>response = requests.post(url, data=payload)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e8c\u3001\u4f7f\u7528BeautifulSoup\u5e93<\/h2>\n<\/p>\n<p><h3>1\u3001\u89e3\u6790HTML\u6587\u6863<\/h3>\n<\/p>\n<p><p>BeautifulSoup\u5e93\u53ef\u4ee5\u7528\u6765\u89e3\u6790HTML\u548cXML\u6587\u6863\uff0c\u5e76\u63d0\u53d6\u9700\u8981\u7684\u6570\u636e\u3002\u8981\u4f7f\u7528BeautifulSoup\u5e93\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5\u5b83\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install beautifulsoup4<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u7136\u540e\uff0c\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u89e3\u6790HTML\u6587\u6863\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from bs4 import BeautifulSoup<\/p>\n<p>html_doc = &quot;&quot;&quot;<\/p>\n<p>&lt;html&gt;&lt;head&gt;&lt;title&gt;The Dormouse&#39;s story&lt;\/title&gt;&lt;\/head&gt;<\/p>\n<p>&lt;body&gt;<\/p>\n<p>&lt;p class=&quot;title&quot;&gt;&lt;b&gt;The Dormouse&#39;s story&lt;\/b&gt;&lt;\/p&gt;<\/p>\n<p>&lt;p class=&quot;story&quot;&gt;Once upon a time there were three little sisters; and their names were<\/p>\n<p>&lt;a href=&quot;http:\/\/example.com\/elsie&quot; class=&quot;sister&quot; id=&quot;link1&quot;&gt;Elsie&lt;\/a&gt;,<\/p>\n<p>&lt;a href=&quot;http:\/\/example.com\/lacie&quot; class=&quot;sister&quot; id=&quot;link2&quot;&gt;Lacie&lt;\/a&gt; and<\/p>\n<p>&lt;a href=&quot;http:\/\/example.com\/tillie&quot; class=&quot;sister&quot; id=&quot;link3&quot;&gt;Tillie&lt;\/a&gt;;<\/p>\n<p>and they lived at the bottom of a well.&lt;\/p&gt;<\/p>\n<p>&lt;p class=&quot;story&quot;&gt;...&lt;\/p&gt;<\/p>\n<p>&quot;&quot;&quot;<\/p>\n<p>soup = BeautifulSoup(html_doc, &#39;html.parser&#39;)<\/p>\n<p>print(soup.prettify())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u63d0\u53d6\u6570\u636e<\/h3>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u4f7f\u7528BeautifulSoup\u63d0\u4f9b\u7684\u5404\u79cd\u65b9\u6cd5\u6765\u63d0\u53d6\u6570\u636e\u3002\u4f8b\u5982\uff1a<\/p>\n<\/p>\n<ul>\n<li><strong>\u627e\u5230\u6240\u6709\u7684\u94fe\u63a5<\/strong>:<\/li>\n<\/ul>\n<p><pre><code class=\"language-python\">for link in soup.find_all(&#39;a&#39;):<\/p>\n<p>    print(link.get(&#39;href&#39;))<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ul>\n<li><strong>\u627e\u5230\u7279\u5b9a\u7684\u6807\u7b7e<\/strong>:<\/li>\n<\/ul>\n<p><pre><code class=\"language-python\">title = soup.title.string<\/p>\n<p>print(title)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<ul>\n<li><strong>\u6839\u636e\u5c5e\u6027\u67e5\u627e\u6807\u7b7e<\/strong>:<\/li>\n<\/ul>\n<p><pre><code class=\"language-python\">link2 = soup.find(id=&#39;link2&#39;)<\/p>\n<p>print(link2.string)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e09\u3001\u4f7f\u7528Scrapy\u6846\u67b6<\/h2>\n<\/p>\n<p><p>Scrapy\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u722c\u866b\u6846\u67b6\uff0c\u9002\u7528\u4e8e\u590d\u6742\u7684\u722c\u53d6\u4efb\u52a1\u3002\u8981\u4f7f\u7528Scrapy\uff0c\u9996\u5148\u9700\u8981\u5b89\u88c5\u5b83\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install scrapy<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>1\u3001\u521b\u5efaScrapy\u9879\u76ee<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Scrapy\u9879\u76ee\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">scrapy startproject myproject<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u5b9a\u4e49Item<\/h3>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u7684<code>items.py<\/code>\u6587\u4ef6\u4e2d\u5b9a\u4e49\u4f60\u8981\u6293\u53d6\u7684\u6570\u636e\u7ed3\u6784\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import scrapy<\/p>\n<p>class MyItem(scrapy.Item):<\/p>\n<p>    title = scrapy.Field()<\/p>\n<p>    link = scrapy.Field()<\/p>\n<p>    desc = scrapy.Field()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u7f16\u5199Spider<\/h3>\n<\/p>\n<p><p>\u5728\u9879\u76ee\u76ee\u5f55\u4e0b\u7684<code>spiders<\/code>\u6587\u4ef6\u5939\u4e2d\u521b\u5efa\u4e00\u4e2a\u65b0\u7684Spider\uff0c\u4f8b\u5982<code>myspider.py<\/code>\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import scrapy<\/p>\n<p>from myproject.items import MyItem<\/p>\n<p>class MySpider(scrapy.Spider):<\/p>\n<p>    name = &#39;myspider&#39;<\/p>\n<p>    start_urls = [&#39;http:\/\/example.com&#39;]<\/p>\n<p>    def parse(self, response):<\/p>\n<p>        for href in response.css(&#39;a::attr(href)&#39;).getall():<\/p>\n<p>            yield response.follow(href, self.parse_det<a href=\"https:\/\/docs.pingcode.com\/blog\/59162.html\" target=\"_blank\">AI<\/a>l)<\/p>\n<p>    def parse_detail(self, response):<\/p>\n<p>        item = MyItem()<\/p>\n<p>        item[&#39;title&#39;] = response.css(&#39;title::text&#39;).get()<\/p>\n<p>        item[&#39;link&#39;] = response.url<\/p>\n<p>        item[&#39;desc&#39;] = response.css(&#39;meta[name=&quot;description&quot;]::attr(content)&#39;).get()<\/p>\n<p>        yield item<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>4\u3001\u8fd0\u884c\u722c\u866b<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u8fd0\u884c\u722c\u866b\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">scrapy crawl myspider<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>5\u3001\u4fdd\u5b58\u6570\u636e<\/h3>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u5c06\u722c\u53d6\u7684\u6570\u636e\u4fdd\u5b58\u5230\u6587\u4ef6\u4e2d\uff0c\u4f8b\u5982JSON\u6587\u4ef6\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">scrapy crawl myspider -o output.json<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u56db\u3001\u5904\u7406\u52a8\u6001\u7f51\u9875<\/h2>\n<\/p>\n<p><p>\u6709\u4e9b\u7f51\u9875\u662f\u901a\u8fc7JavaScript\u52a8\u6001\u751f\u6210\u5185\u5bb9\u7684\uff0c\u4f7f\u7528requests\u548cBeautifulSoup\u53ef\u80fd\u65e0\u6cd5\u83b7\u53d6\u8fd9\u4e9b\u5185\u5bb9\u3002\u6b64\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528Selenium\u5e93\u6765\u5904\u7406\u52a8\u6001\u7f51\u9875\u3002<\/p>\n<\/p>\n<p><h3>1\u3001\u5b89\u88c5Selenium<\/h3>\n<\/p>\n<p><p>\u9996\u5148\uff0c\u5b89\u88c5Selenium\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-bash\">pip install selenium<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u4e0b\u8f7dWebDriver<\/h3>\n<\/p>\n<p><p>Selenium\u9700\u8981\u4f7f\u7528WebDriver\u6765\u63a7\u5236\u6d4f\u89c8\u5668\u3002\u6839\u636e\u4f60\u4f7f\u7528\u7684\u6d4f\u89c8\u5668\u4e0b\u8f7d\u76f8\u5e94\u7684WebDriver\uff0c\u4f8b\u5982ChromeDriver\u3002<\/p>\n<\/p>\n<p><h3>3\u3001\u4f7f\u7528Selenium\u83b7\u53d6\u7f51\u9875\u5185\u5bb9<\/h3>\n<\/p>\n<p><p>\u4ee5\u4e0b\u662f\u4e00\u4e2a\u4f7f\u7528Selenium\u83b7\u53d6\u52a8\u6001\u7f51\u9875\u5185\u5bb9\u7684\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from selenium import webdriver<\/p>\n<h2><strong>\u521d\u59cb\u5316WebDriver<\/strong><\/h2>\n<p>driver = webdriver.Chrome(executable_path=&#39;\/path\/to\/chromedriver&#39;)<\/p>\n<h2><strong>\u6253\u5f00\u7f51\u9875<\/strong><\/h2>\n<p>driver.get(&#39;http:\/\/example.com&#39;)<\/p>\n<h2><strong>\u83b7\u53d6\u7f51\u9875\u5185\u5bb9<\/strong><\/h2>\n<p>html = driver.page_source<\/p>\n<p>print(html)<\/p>\n<h2><strong>\u5173\u95ed\u6d4f\u89c8\u5668<\/strong><\/h2>\n<p>driver.quit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>4\u3001\u7ed3\u5408BeautifulSoup\u89e3\u6790\u5185\u5bb9<\/h3>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u5c06Selenium\u83b7\u53d6\u7684\u7f51\u9875\u5185\u5bb9\u4e0eBeautifulSoup\u7ed3\u5408\uff0c\u89e3\u6790\u5e76\u63d0\u53d6\u6570\u636e\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from selenium import webdriver<\/p>\n<p>from bs4 import BeautifulSoup<\/p>\n<h2><strong>\u521d\u59cb\u5316WebDriver<\/strong><\/h2>\n<p>driver = webdriver.Chrome(executable_path=&#39;\/path\/to\/chromedriver&#39;)<\/p>\n<h2><strong>\u6253\u5f00\u7f51\u9875<\/strong><\/h2>\n<p>driver.get(&#39;http:\/\/example.com&#39;)<\/p>\n<h2><strong>\u83b7\u53d6\u7f51\u9875\u5185\u5bb9<\/strong><\/h2>\n<p>html = driver.page_source<\/p>\n<h2><strong>\u4f7f\u7528BeautifulSoup\u89e3\u6790\u5185\u5bb9<\/strong><\/h2>\n<p>soup = BeautifulSoup(html, &#39;html.parser&#39;)<\/p>\n<p>print(soup.prettify())<\/p>\n<h2><strong>\u5173\u95ed\u6d4f\u89c8\u5668<\/strong><\/h2>\n<p>driver.quit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e94\u3001\u5904\u7406\u7ffb\u9875\u548c\u8868\u5355\u63d0\u4ea4<\/h2>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u7684\u722c\u866b\u4efb\u52a1\u4e2d\uff0c\u53ef\u80fd\u9700\u8981\u5904\u7406\u7ffb\u9875\u548c\u8868\u5355\u63d0\u4ea4\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u793a\u4f8b\u4ee3\u7801\uff1a<\/p>\n<\/p>\n<p><h3>1\u3001\u5904\u7406\u7ffb\u9875<\/h3>\n<\/p>\n<p><p>\u5047\u8bbe\u7f51\u9875\u6709\u4e00\u4e2a\u201c\u4e0b\u4e00\u9875\u201d\u6309\u94ae\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u5904\u7406\u7ffb\u9875\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>from bs4 import BeautifulSoup<\/p>\n<p>url = &#39;http:\/\/example.com\/page1&#39;<\/p>\n<p>while url:<\/p>\n<p>    response = requests.get(url)<\/p>\n<p>    soup = BeautifulSoup(response.text, &#39;html.parser&#39;)<\/p>\n<p>    # \u63d0\u53d6\u6570\u636e<\/p>\n<p>    for item in soup.select(&#39;.item&#39;):<\/p>\n<p>        print(item.text)<\/p>\n<p>    # \u627e\u5230\u201c\u4e0b\u4e00\u9875\u201d\u6309\u94ae<\/p>\n<p>    next_button = soup.select_one(&#39;.next&#39;)<\/p>\n<p>    if next_button:<\/p>\n<p>        url = next_button.get(&#39;href&#39;)<\/p>\n<p>    else:<\/p>\n<p>        url = None<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u5904\u7406\u8868\u5355\u63d0\u4ea4<\/h3>\n<\/p>\n<p><p>\u5047\u8bbe\u7f51\u9875\u6709\u4e00\u4e2a\u641c\u7d22\u8868\u5355\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u63d0\u4ea4\u8868\u5355\u5e76\u83b7\u53d6\u7ed3\u679c\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>from bs4 import BeautifulSoup<\/p>\n<p>url = &#39;http:\/\/example.com\/search&#39;<\/p>\n<p>payload = {&#39;q&#39;: &#39;keyword&#39;}<\/p>\n<p>response = requests.post(url, data=payload)<\/p>\n<p>soup = BeautifulSoup(response.text, &#39;html.parser&#39;)<\/p>\n<h2><strong>\u63d0\u53d6\u6570\u636e<\/strong><\/h2>\n<p>for item in soup.select(&#39;.result&#39;):<\/p>\n<p>    print(item.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u516d\u3001\u5904\u7406Cookies\u548cSession<\/h2>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u722c\u866b\u9700\u8981\u5904\u7406Cookies\u548cSession\u3002requests\u5e93\u63d0\u4f9b\u4e86Session\u5bf9\u8c61\uff0c\u53ef\u4ee5\u7528\u6765\u5904\u7406\u8fd9\u4e9b\u60c5\u51b5\uff1a<\/p>\n<\/p>\n<p><h3>1\u3001\u4f7f\u7528Session\u5bf9\u8c61<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528Session\u5bf9\u8c61\u53ef\u4ee5\u5728\u591a\u4e2a\u8bf7\u6c42\u4e4b\u95f4\u4fdd\u6301Cookies\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<h2><strong>\u521b\u5efaSession\u5bf9\u8c61<\/strong><\/h2>\n<p>session = requests.Session()<\/p>\n<h2><strong>\u53d1\u9001\u7b2c\u4e00\u4e2a\u8bf7\u6c42<\/strong><\/h2>\n<p>url = &#39;http:\/\/example.com\/login&#39;<\/p>\n<p>payload = {&#39;username&#39;: &#39;user&#39;, &#39;password&#39;: &#39;pass&#39;}<\/p>\n<p>response = session.post(url, data=payload)<\/p>\n<h2><strong>\u53d1\u9001\u7b2c\u4e8c\u4e2a\u8bf7\u6c42<\/strong><\/h2>\n<p>url = &#39;http:\/\/example.com\/profile&#39;<\/p>\n<p>response = session.get(url)<\/p>\n<p>print(response.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u5904\u7406Cookies<\/h3>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u624b\u52a8\u8bbe\u7f6e\u548c\u83b7\u53d6Cookies\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<h2><strong>\u521b\u5efaSession\u5bf9\u8c61<\/strong><\/h2>\n<p>session = requests.Session()<\/p>\n<h2><strong>\u8bbe\u7f6eCookies<\/strong><\/h2>\n<p>session.cookies.set(&#39;cookie_name&#39;, &#39;cookie_value&#39;)<\/p>\n<h2><strong>\u53d1\u9001\u8bf7\u6c42<\/strong><\/h2>\n<p>url = &#39;http:\/\/example.com&#39;<\/p>\n<p>response = session.get(url)<\/p>\n<h2><strong>\u83b7\u53d6Cookies<\/strong><\/h2>\n<p>print(session.cookies.get_dict())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e03\u3001\u5904\u7406\u5f02\u6b65\u8bf7\u6c42<\/h2>\n<\/p>\n<p><p>\u6709\u4e9b\u7f51\u9875\u4f1a\u4f7f\u7528\u5f02\u6b65\u8bf7\u6c42\uff08\u5982AJAX\uff09\u52a0\u8f7d\u6570\u636e\u3002\u4f60\u53ef\u4ee5\u4f7f\u7528requests\u5e93\u53d1\u9001\u5f02\u6b65\u8bf7\u6c42\uff0c\u5e76\u83b7\u53d6\u6570\u636e\uff1a<\/p>\n<\/p>\n<p><h3>1\u3001\u53d1\u9001\u5f02\u6b65\u8bf7\u6c42<\/h3>\n<\/p>\n<p><p>\u5047\u8bbe\u7f51\u9875\u901a\u8fc7AJAX\u8bf7\u6c42\u83b7\u53d6\u6570\u636e\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u4ee3\u7801\u53d1\u9001\u5f02\u6b65\u8bf7\u6c42\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>url = &#39;http:\/\/example.com\/api\/data&#39;<\/p>\n<p>response = requests.get(url)<\/p>\n<p>print(response.json())<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u7ed3\u5408Selenium\u5904\u7406\u5f02\u6b65\u8bf7\u6c42<\/h3>\n<\/p>\n<p><p>\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u4f7f\u7528requests\u5e93\u53ef\u80fd\u65e0\u6cd5\u83b7\u53d6\u5f02\u6b65\u8bf7\u6c42\u7684\u6570\u636e\u3002\u6b64\u65f6\uff0c\u53ef\u4ee5\u4f7f\u7528Selenium\u6765\u5904\u7406\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from selenium import webdriver<\/p>\n<p>import json<\/p>\n<h2><strong>\u521d\u59cb\u5316WebDriver<\/strong><\/h2>\n<p>driver = webdriver.Chrome(executable_path=&#39;\/path\/to\/chromedriver&#39;)<\/p>\n<h2><strong>\u6253\u5f00\u7f51\u9875<\/strong><\/h2>\n<p>driver.get(&#39;http:\/\/example.com&#39;)<\/p>\n<h2><strong>\u7b49\u5f85\u5f02\u6b65\u8bf7\u6c42\u5b8c\u6210<\/strong><\/h2>\n<p>driver.implicitly_wait(10)<\/p>\n<h2><strong>\u83b7\u53d6\u5f02\u6b65\u8bf7\u6c42\u7684\u6570\u636e<\/strong><\/h2>\n<p>html = driver.page_source<\/p>\n<p>data = json.loads(html)<\/p>\n<p>print(data)<\/p>\n<h2><strong>\u5173\u95ed\u6d4f\u89c8\u5668<\/strong><\/h2>\n<p>driver.quit()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u516b\u3001\u5904\u7406\u53cd\u722c\u866b\u673a\u5236<\/h2>\n<\/p>\n<p><p>\u5f88\u591a\u7f51\u7ad9\u90fd\u6709\u53cd\u722c\u866b\u673a\u5236\uff0c\u5982IP\u5c01\u7981\u3001\u9a8c\u8bc1\u7801\u7b49\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e94\u5bf9\u63aa\u65bd\uff1a<\/p>\n<\/p>\n<p><h3>1\u3001\u4f7f\u7528\u4ee3\u7406<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u4ee3\u7406\u53ef\u4ee5\u9690\u85cf\u4f60\u7684\u771f\u5b9eIP\u5730\u5740\uff0c\u5e76\u6a21\u62df\u4e0d\u540c\u7684\u7528\u6237\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>proxies = {<\/p>\n<p>    &#39;http&#39;: &#39;http:\/\/10.10.10.10:8000&#39;,<\/p>\n<p>    &#39;https&#39;: &#39;http:\/\/10.10.10.10:8000&#39;,<\/p>\n<p>}<\/p>\n<p>response = requests.get(&#39;http:\/\/example.com&#39;, proxies=proxies)<\/p>\n<p>print(response.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u8bbe\u7f6e\u8bf7\u6c42\u5934<\/h3>\n<\/p>\n<p><p>\u8bbe\u7f6e\u8bf7\u6c42\u5934\u53ef\u4ee5\u6a21\u62df\u771f\u5b9e\u7684\u6d4f\u89c8\u5668\u8bf7\u6c42\uff0c\u907f\u514d\u88ab\u53cd\u722c\u866b\u673a\u5236\u68c0\u6d4b\u5230\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import requests<\/p>\n<p>headers = {<\/p>\n<p>    &#39;User-Agent&#39;: &#39;Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/58.0.3029.110 Safari\/537.3&#39;<\/p>\n<p>}<\/p>\n<p>response = requests.get(&#39;http:\/\/example.com&#39;, headers=headers)<\/p>\n<p>print(response.text)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u5904\u7406\u9a8c\u8bc1\u7801<\/h3>\n<\/p>\n<p><p>\u5904\u7406\u9a8c\u8bc1\u7801\u662f\u4e00\u9879\u590d\u6742\u7684\u4efb\u52a1\uff0c\u901a\u5e38\u9700\u8981\u4f7f\u7528OCR\u6280\u672f\u6216\u7b2c\u4e09\u65b9\u6253\u7801\u5e73\u53f0\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528Pytesseract\u5e93\u5904\u7406\u56fe\u7247\u9a8c\u8bc1\u7801\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pytesseract<\/p>\n<p>from PIL import Image<\/p>\n<h2><strong>\u52a0\u8f7d\u9a8c\u8bc1\u7801\u56fe\u7247<\/strong><\/h2>\n<p>image = Image.open(&#39;captcha.png&#39;)<\/p>\n<h2><strong>\u4f7f\u7528Pytesseract\u8bc6\u522b\u9a8c\u8bc1\u7801<\/strong><\/h2>\n<p>captcha = pytesseract.image_to_string(image)<\/p>\n<p>print(captcha)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u4e5d\u3001\u6570\u636e\u5b58\u50a8\u548c\u5904\u7406<\/h2>\n<\/p>\n<p><p>\u722c\u53d6\u5230\u7684\u6570\u636e\u9700\u8981\u8fdb\u884c\u5b58\u50a8\u548c\u5904\u7406\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><h3>1\u3001\u5b58\u50a8\u5230\u6587\u4ef6<\/h3>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u5c06\u6570\u636e\u5b58\u50a8\u5230\u5404\u79cd\u6587\u4ef6\u683c\u5f0f\u4e2d\uff0c\u5982CSV\u3001JSON\u3001TXT\u7b49\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import csv<\/p>\n<p>import json<\/p>\n<h2><strong>\u5b58\u50a8\u5230CSV\u6587\u4ef6<\/strong><\/h2>\n<p>data = [[&#39;Name&#39;, &#39;Age&#39;], [&#39;Alice&#39;, 25], [&#39;Bob&#39;, 30]]<\/p>\n<p>with open(&#39;data.csv&#39;, &#39;w&#39;, newline=&#39;&#39;) as file:<\/p>\n<p>    writer = csv.writer(file)<\/p>\n<p>    writer.writerows(data)<\/p>\n<h2><strong>\u5b58\u50a8\u5230JSON\u6587\u4ef6<\/strong><\/h2>\n<p>data = {&#39;name&#39;: &#39;Alice&#39;, &#39;age&#39;: 25}<\/p>\n<p>with open(&#39;data.json&#39;, &#39;w&#39;) as file:<\/p>\n<p>    json.dump(data, file)<\/p>\n<h2><strong>\u5b58\u50a8\u5230TXT\u6587\u4ef6<\/strong><\/h2>\n<p>data = &#39;Hello, world!&#39;<\/p>\n<p>with open(&#39;data.txt&#39;, &#39;w&#39;) as file:<\/p>\n<p>    file.write(data)<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u5b58\u50a8\u5230\u6570\u636e\u5e93<\/h3>\n<\/p>\n<p><p>\u4f60\u53ef\u4ee5\u5c06\u6570\u636e\u5b58\u50a8\u5230\u5404\u79cd\u6570\u636e\u5e93\u4e2d\uff0c\u5982SQLite\u3001MySQL\u3001MongoDB\u7b49\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import sqlite3<\/p>\n<p>import pymysql<\/p>\n<p>import pymongo<\/p>\n<h2><strong>\u5b58\u50a8\u5230SQLite<\/strong><\/h2>\n<p>conn = sqlite3.connect(&#39;data.db&#39;)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<p>cursor.execute(&#39;CREATE TABLE IF NOT EXISTS users (name TEXT, age INTEGER)&#39;)<\/p>\n<p>cursor.execute(&#39;INSERT INTO users (name, age) VALUES (?, ?)&#39;, (&#39;Alice&#39;, 25))<\/p>\n<p>conn.commit()<\/p>\n<p>conn.close()<\/p>\n<h2><strong>\u5b58\u50a8\u5230MySQL<\/strong><\/h2>\n<p>conn = pymysql.connect(host=&#39;localhost&#39;, user=&#39;root&#39;, password=&#39;password&#39;, database=&#39;test&#39;)<\/p>\n<p>cursor = conn.cursor()<\/p>\n<p>cursor.execute(&#39;CREATE TABLE IF NOT EXISTS users (name VARCHAR(255), age INT)&#39;)<\/p>\n<p>cursor.execute(&#39;INSERT INTO users (name, age) VALUES (%s, %s)&#39;, (&#39;Alice&#39;, 25))<\/p>\n<p>conn.commit()<\/p>\n<p>conn.close()<\/p>\n<h2><strong>\u5b58\u50a8\u5230MongoDB<\/strong><\/h2>\n<p>client = pymongo.MongoClient(&#39;mongodb:\/\/localhost:27017\/&#39;)<\/p>\n<p>db = client[&#39;test&#39;]<\/p>\n<p>collection = db[&#39;users&#39;]<\/p>\n<p>collection.insert_one({&#39;name&#39;: &#39;Alice&#39;, &#39;age&#39;: 25})<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u6570\u636e\u5904\u7406\u548c\u5206\u6790<\/h3>\n<\/p>\n<p><p>\u722c\u53d6\u5230\u7684\u6570\u636e\u901a\u5e38\u9700\u8981\u8fdb\u884c\u5904\u7406\u548c\u5206\u6790\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import pandas as pd<\/p>\n<p>import numpy as np<\/p>\n<h2><strong>\u52a0\u8f7d\u6570\u636e<\/strong><\/h2>\n<p>data = pd.read_csv(&#39;data.csv&#39;)<\/p>\n<h2><strong>\u6570\u636e\u6e05\u6d17<\/strong><\/h2>\n<p>data.dropna(inplace=True)<\/p>\n<p>data[&#39;Age&#39;] = data[&#39;Age&#39;].astype(int)<\/p>\n<h2><strong>\u6570\u636e\u5206\u6790<\/strong><\/h2>\n<p>mean_age = data[&#39;Age&#39;].mean()<\/p>\n<p>print(f&#39;\u5e73\u5747\u5e74\u9f84: {mean_age}&#39;)<\/p>\n<h2><strong>\u6570\u636e\u53ef\u89c6\u5316<\/strong><\/h2>\n<p>data.hist(column=&#39;Age&#39;)<\/p>\n<p>import matplotlib.pyplot as plt<\/p>\n<p>plt.show()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h2>\u5341\u3001\u722c\u866b\u7ba1\u7406\u548c\u8c03\u5ea6<\/h2>\n<\/p>\n<p><p>\u5728\u5b9e\u9645\u7684\u722c\u866b\u4efb\u52a1\u4e2d\uff0c\u53ef\u80fd\u9700\u8981\u7ba1\u7406\u548c\u8c03\u5ea6\u591a\u4e2a\u722c\u866b\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u65b9\u6cd5\uff1a<\/p>\n<\/p>\n<p><h3>1\u3001\u4f7f\u7528\u591a\u7ebf\u7a0b<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u591a\u7ebf\u7a0b\u53ef\u4ee5\u63d0\u9ad8\u722c\u866b\u7684\u6548\u7387\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import threading<\/p>\n<p>import requests<\/p>\n<p>def fetch_url(url):<\/p>\n<p>    response = requests.get(url)<\/p>\n<p>    print(response.text)<\/p>\n<p>urls = [&#39;http:\/\/example.com\/page1&#39;, &#39;http:\/\/example.com\/page2&#39;, &#39;http:\/\/example.com\/page3&#39;]<\/p>\n<p>threads = []<\/p>\n<p>for url in urls:<\/p>\n<p>    thread = threading.Thread(target=fetch_url, args=(url,))<\/p>\n<p>    thread.start()<\/p>\n<p>    threads.append(thread)<\/p>\n<p>for thread in threads:<\/p>\n<p>    thread.join()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>2\u3001\u4f7f\u7528\u591a\u8fdb\u7a0b<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u591a\u8fdb\u7a0b\u53ef\u4ee5\u63d0\u9ad8\u722c\u866b\u7684\u6548\u7387\uff0c\u5e76\u907f\u514dGIL\u7684\u9650\u5236\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">import multiprocessing<\/p>\n<p>import requests<\/p>\n<p>def fetch_url(url):<\/p>\n<p>    response = requests.get(url)<\/p>\n<p>    print(response.text)<\/p>\n<p>urls = [&#39;http:\/\/example.com\/page1&#39;, &#39;http:\/\/example.com\/page2&#39;, &#39;http:\/\/example.com\/page3&#39;]<\/p>\n<p>processes = []<\/p>\n<p>for url in urls:<\/p>\n<p>    process = multiprocessing.Process(target=fetch_url, args=(url,))<\/p>\n<p>    process.start()<\/p>\n<p>    processes.append(process)<\/p>\n<p>for process in processes:<\/p>\n<p>    process.join()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><h3>3\u3001\u4f7f\u7528\u8c03\u5ea6\u5668<\/h3>\n<\/p>\n<p><p>\u4f7f\u7528\u8c03\u5ea6\u5668\u53ef\u4ee5\u5b9a\u65f6\u8fd0\u884c\u722c\u866b\u4efb\u52a1\u3002\u4f8b\u5982\uff0c\u53ef\u4ee5\u4f7f\u7528APScheduler\u5e93\uff1a<\/p>\n<\/p>\n<p><pre><code class=\"language-python\">from apscheduler.schedulers.blocking import BlockingScheduler<\/p>\n<p>import requests<\/p>\n<p>def fetch_url():<\/p>\n<p>    response = requests.get(&#39;http:\/\/example.com&#39;)<\/p>\n<p>    print(response.text)<\/p>\n<p>scheduler = BlockingScheduler()<\/p>\n<p>scheduler.add_job(fetch_url, &#39;interval&#39;, minutes=1)<\/p>\n<p>scheduler.start()<\/p>\n<p><\/code><\/pre>\n<\/p>\n<p><p>\u603b\u4e4b\uff0cPython\u63d0\u4f9b\u4e86\u4e30\u5bcc\u7684\u5e93\u548c\u5de5\u5177\u6765\u81ea\u52a8\u722c\u53d6\u6570\u636e\u3002\u901a\u8fc7\u5408\u7406\u4f7f\u7528\u8fd9\u4e9b\u5de5\u5177\uff0c\u4f60\u53ef\u4ee5\u9ad8\u6548\u5730\u5b8c\u6210\u5404\u79cd\u722c\u866b\u4efb\u52a1\u3002\u65e0\u8bba\u662f\u7b80\u5355\u7684\u7f51\u9875\u6570\u636e\u722c\u53d6\uff0c\u8fd8\u662f\u590d\u6742\u7684\u52a8\u6001\u7f51\u9875\u5904\u7406\uff0cPython\u90fd\u80fd\u63d0\u4f9b\u5f3a\u5927\u7684\u652f\u6301\u3002\u540c\u65f6\uff0c\u722c\u866b\u8fc7\u7a0b\u4e2d\u5e94\u9075\u5b88\u76f8\u5173\u6cd5\u5f8b\u6cd5\u89c4\uff0c\u5c0a\u91cd\u7f51\u7ad9\u7684robots.txt\u534f\u8bae\u548c\u9690\u79c1\u653f\u7b56\u3002<\/p>\n<\/p>\n<h2><strong>\u76f8\u5173\u95ee\u7b54FAQs\uff1a<\/strong><\/h2>\n<p> <strong>\u5982\u4f55\u9009\u62e9\u5408\u9002\u7684Python\u5e93\u6765\u8fdb\u884c\u6570\u636e\u722c\u53d6\uff1f<\/strong><br \/>\u5728\u8fdb\u884c\u6570\u636e\u722c\u53d6\u65f6\uff0c\u9009\u62e9\u5408\u9002\u7684Python\u5e93\u81f3\u5173\u91cd\u8981\u3002\u5e38\u7528\u7684\u5e93\u5305\u62ecBeautiful Soup\u3001Scrapy\u548cRequests\u3002Beautiful Soup\u9002\u5408\u89e3\u6790HTML\u548cXML\u6587\u6863\uff0c\u975e\u5e38\u6613\u4e8e\u4f7f\u7528\uff1bScrapy\u662f\u4e00\u4e2a\u529f\u80fd\u5f3a\u5927\u7684\u6846\u67b6\uff0c\u9002\u5408\u5904\u7406\u5927\u578b\u722c\u866b\u9879\u76ee\uff0c\u5e76\u5177\u5907\u5f02\u6b65\u5904\u7406\u80fd\u529b\uff1bRequests\u5e93\u5219\u7528\u4e8e\u53d1\u9001\u7f51\u7edc\u8bf7\u6c42\uff0c\u7b80\u5355\u6613\u61c2\uff0c\u975e\u5e38\u9002\u5408\u521d\u5b66\u8005\u3002<\/p>\n<p><strong>\u5728\u722c\u53d6\u6570\u636e\u65f6\uff0c\u5982\u4f55\u5904\u7406\u53cd\u722c\u866b\u673a\u5236\uff1f<\/strong><br \/>\u8bb8\u591a\u7f51\u7ad9\u4f1a\u8bbe\u7f6e\u53cd\u722c\u866b\u673a\u5236\u6765\u4fdd\u62a4\u6570\u636e\uff0c\u56e0\u6b64\u5728\u722c\u53d6\u65f6\u8981\u8003\u8651\u5982\u4f55\u89c4\u907f\u8fd9\u4e9b\u673a\u5236\u3002\u53ef\u4ee5\u901a\u8fc7\u6a21\u62df\u771f\u5b9e\u7528\u6237\u7684\u884c\u4e3a\uff0c\u4f8b\u5982\u8bbe\u7f6e\u968f\u673a\u7684\u7528\u6237\u4ee3\u7406\u3001\u4f7f\u7528\u4ee3\u7406IP\u3001\u8c03\u6574\u8bf7\u6c42\u9891\u7387\u3001\u5f15\u5165\u968f\u673a\u5ef6\u8fdf\u7b49\u65b9\u5f0f\u6765\u51cf\u5c11\u88ab\u68c0\u6d4b\u7684\u98ce\u9669\u3002\u6b64\u5916\uff0c\u5206\u6790\u7f51\u7ad9\u7684robots.txt\u6587\u4ef6\u4e5f\u662f\u4e2a\u597d\u4e60\u60ef\uff0c\u5b83\u53ef\u4ee5\u5e2e\u52a9\u4e86\u89e3\u54ea\u4e9b\u9875\u9762\u662f\u5141\u8bb8\u722c\u53d6\u7684\u3002<\/p>\n<p><strong>\u722c\u53d6\u7684\u6570\u636e\u5982\u4f55\u8fdb\u884c\u5b58\u50a8\u548c\u5206\u6790\uff1f<\/strong><br \/>\u4e00\u65e6\u6210\u529f\u722c\u53d6\u5230\u6570\u636e\uff0c\u5b58\u50a8\u548c\u5206\u6790\u5c31\u662f\u4e0b\u4e00\u4e2a\u91cd\u8981\u6b65\u9aa4\u3002\u53ef\u4ee5\u9009\u62e9\u5c06\u6570\u636e\u5b58\u50a8\u5728CSV\u6587\u4ef6\u3001\u6570\u636e\u5e93\uff08\u5982SQLite\u3001MySQL\uff09\u6216NoSQL\u6570\u636e\u5e93\uff08\u5982MongoDB\uff09\u4e2d\u3002\u5bf9\u4e8e\u6570\u636e\u5206\u6790\uff0c\u4f7f\u7528Pandas\u5e93\u53ef\u4ee5\u65b9\u4fbf\u5730\u5904\u7406\u548c\u5206\u6790\u6570\u636e\uff0c\u751f\u6210\u56fe\u8868\u548c\u62a5\u544a\uff0c\u5e2e\u52a9\u7528\u6237\u66f4\u597d\u5730\u7406\u89e3\u548c\u5229\u7528\u6240\u722c\u53d6\u7684\u4fe1\u606f\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"Python\u81ea\u52a8\u722c\u53d6\u6570\u636e\u7684\u65b9\u6cd5\u4e3b\u8981\u5305\u62ec\u4f7f\u7528requests\u5e93\u3001\u4f7f\u7528BeautifulSoup\u5e93\u3001\u4f7f\u7528Scrap [&hellip;]","protected":false},"author":3,"featured_media":1171289,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[37],"tags":[],"acf":[],"_links":{"self":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1171279"}],"collection":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/comments?post=1171279"}],"version-history":[{"count":"1","href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1171279\/revisions"}],"predecessor-version":[{"id":1171291,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/posts\/1171279\/revisions\/1171291"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media\/1171289"}],"wp:attachment":[{"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/media?parent=1171279"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/categories?post=1171279"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/docs.pingcode.com\/wp-json\/wp\/v2\/tags?post=1171279"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}