python3抓取中文網頁的方法
來源:懂視網
責編:小采
時間:2020-11-27 14:42:07
python3抓取中文網頁的方法
python3抓取中文網頁的方法:本文實例講述了python3抓取中文網頁的方法。分享給大家供大家參考。具體如下: #! /usr/bin/python3.2 import sys import urllib.request req = urllib.request.Request('http://www.baidu.com') response = u
導讀python3抓取中文網頁的方法:本文實例講述了python3抓取中文網頁的方法。分享給大家供大家參考。具體如下: #! /usr/bin/python3.2 import sys import urllib.request req = urllib.request.Request('http://www.baidu.com') response = u

本文實例講述了python3抓取中文網頁的方法。分享給大家供大家參考。具體如下:
#! /usr/bin/python3.2
import sys
import urllib.request
req = 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程序設計有所幫助。
聲明:本網頁內容旨在傳播知識,若有侵權等問題請及時與本網聯系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com
python3抓取中文網頁的方法
python3抓取中文網頁的方法:本文實例講述了python3抓取中文網頁的方法。分享給大家供大家參考。具體如下: #! /usr/bin/python3.2 import sys import urllib.request req = urllib.request.Request('http://www.baidu.com') response = u