pycharm爬蟲列印網頁出現中文亂碼問題

2021-09-28 23:59:13 字數 458 閱讀 3512

今天爬了一天的微博,到現在還沒有成功。期間也出現了列印頁面中文顯示亂碼問題。

html=session.get(url)

print(html.text)

如果直接列印的話就會出現這樣的結果

è·èï

這個問題真的卡了好久,後來找了各種文章,原來是網頁編碼問題。

print(html.encoding)

iso-8859-1

發現編碼是iso-8859-1形式的,我們需要改為gbk格式的就能正常顯示了

html=session.get(url)

#pycharm解決爬蟲中文亂碼問題

html.encoding = 'gbk'

print(html.encoding)

手機號不能為空

登入

pycharm爬蟲列印網頁出現中文亂碼問題

方法一 response requests.get url,verify false response.encoding gbk 將得到的response編碼轉換一下即可。方法二 beautifulsoup解析後得到的soup,列印出來是亂碼,實際上其本身已經是正確的 從原始的gb2312編碼 解析...

網頁爬蟲php,php網頁爬蟲

網頁爬蟲 最簡單的使用,屬性都採用預設值 curl curl init output curl exec curl curl close curl echo output 稍微複雜一點的,對頁面進行操作 curl curl init curl setopt curl,curlopt url,可以動態...

pycharm出現卡頓

使用pycharm時常出現 the ide is running low on memory 的問題,表示pycharm這款ide使用記憶體不足,需要在系統記憶體充足的情況下擴充ide memory。右下角會出現 然後,在pycharm右上角工具欄選中 help find action 輸入vm o...