初識網頁urllib模塊

來源【www.51dali.cn
#網絡爬蟲:網頁蜘蛛
#網絡是個只蜘蛛網,蜘蛛在網頁上爬
#搜索引擎就是爬蟲,爬數據,鑑定索引,建立數據庫,然後排序
#爬蟲代碼
#問題:
#1.Python如何訪問互聯網 urllib模塊;

url 網址

libs 網頁

#Python3怎麼查詢網站

response = urllib.response.urlopen(’’)

html = response.read()

html = html.decode(‘utf-8’)

#print(html) 源代碼
#Python實戰
import urllib.request
response = urllib.request.urlopen(‘http://placekitten.com/g/200/300’)
cat_imf = response.read()
with open(‘cat_500_600.jpg’,‘wb’) as f:
f.write(cat_imf)
【java1234】

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章