【Python】url基础:网络爬虫技术
生活随笔
收集整理的這篇文章主要介紹了
【Python】url基础:网络爬虫技术
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
使用urllib.request請求一個網頁內容
自動解碼器 conda install chardet
from urllib import request import chardetif __name__ =='__main__':#獲取網址url = "http://ts.zhaopin.com/jump/index_new.html?utm_source=other&utm_medium=cnt&utm_term=&utm_campaign=121113803&utm_provider=zp&sid=121113803&site=pzzhubiaoti"#發送請求rsp = request.urlopen(url)#讀取返回結果html = rsp.read()print(type(html))#html解碼,調用自動解碼器cs = chardet.detect(html)html = html.decode(cs.get("encoding","utf-8"))print(html) 《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
以上是生活随笔為你收集整理的【Python】url基础:网络爬虫技术的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 【Python】文件序列化——文件编码机
- 下一篇: 【Python】进制转换