本文實例講述了python3抓取中文網頁的方法。分享給大家供大家參考。具體如下:
#! /usr/bin/python3.2import sysimport urllib.requestreq = urllib.request.Request('http://www.baidu.com')response = urllib.request.urlopen(req)the_page = response.read()type = sys.getfilesystemencoding()#轉換成本地系統編碼print(the_page.decode(type))希望本文所述對大家的Python程序設計有所幫助。
新聞熱點
疑難解答
圖片精選