1. 程式人生 > >一個超級簡易爬蟲

一個超級簡易爬蟲

 超級簡易版爬蟲
from urllib.request import urlopen # 匯入一個模組
 幹掉數字簽名
 import ssl
ssl._create_default_https_context = ssl._create_unverified_context


 def func():
 獲取到網頁中的內容, 當網速很慢的時候. 反覆的去開啟這個網站. 很慢
 content = urlopen("https://www.dytt8.net/").read()

 def inner():
 return content.decode("gbk") # 網頁內容
 return inner

 print("開始網路請求")
 ret = func() # 網路請求已經完畢
 print("網路請求完畢")
 print("第一次", ret()[5])
 print("第二次", ret()[5])