<kbd id="9plqc"><label id="9plqc"></label></kbd>

        <th id="9plqc"></th>
        1. <center id="9plqc"><video id="9plqc"></video></center>
          <sub id="9plqc"><form id="9plqc"><pre id="9plqc"></pre></form></sub>
          <nav id="9plqc"><form id="9plqc"><legend id="9plqc"></legend></form></nav>
          python 爬蟲編碼(encoding和apparent 您所在的位置:網(wǎng)站首頁 什么網(wǎng)(wǎng)名財運好女 python 爬蟲編碼(encoding和apparent

          python 爬蟲編碼(encoding和apparent

          2023-07-08 19:29| 來源: 網(wǎng)絡(luò)整理| 查看: 265

          前言

          在爬蟲有時會遇到類似?¥???????é?3?1?????¥???????MVé????¨è??é???o?????????¢è?°??????????????a? 3?3¨??|???格式的編碼,很是頭疼。如何解決這種問題呢?下面來看一下編碼方法

          requests編碼 屬性 說明 r.encoding 從http header中提取響應(yīng)內(nèi)容編碼 r.apparent_encoding 從內(nèi)容中分析出的響應(yīng)內(nèi)容編碼 encoding是從http中的header中的charset字段中提取的編碼方式,若header中沒有charset字段則默認為ISO-8859-1編碼模式,則無法解析中文,這是亂碼的原因。 apparent_encoding會從網(wǎng)頁的內(nèi)容中分析網(wǎng)頁編碼的方式,所以apparent_encoding比encoding更加準確。當網(wǎng)頁出現(xiàn)亂碼時可以把apparent_encoding的編碼格式賦值給encoding。 解決亂碼 import requests url = "********" reqs= requests.get(url) reqs.encoding = reqs.apparent_encoding print(reqs.text)


          【本文地址】

          公司簡介

          聯(lián)系我們

          今日新聞

          推薦新聞

          專題文章
            CopyRight 2018-2019 實驗室設(shè)備網(wǎng) 版權(quán)所有
            黄色免费网站在线看,韩国精品在线观看,韩国美女一区二区,99国产热 浠水县| 三亚市| 通州区| 台江县| 威宁| 旺苍县| 木兰县| 株洲县| 靖州| 永年县| 两当县| 平利县| 海原县| 青州市| 东乡县| 青岛市| 阿坝县| 茌平县| 安吉县| 万盛区| 锡林郭勒盟| 和田县| 万源市| 田林县| 三门县| 荣昌县| 离岛区| 沙洋县| 呼玛县| 于田县| 荔浦县| 江安县| 文安县| 清原| 专栏| 上栗县| 定陶县| 桦南县| 射阳县| 教育| 温宿县| http://444 http://444 http://444 http://444 http://444 http://444