urlencode()函數(shù)可用來構(gòu)造URL的請(qǐng)求參數(shù)
from urllib.parse import urlencode
params = {
'offset': offest,
'format':'json',
'keyword':'街拍',
'autoload':'true',
'count':'20',
'cur_tab':'3',
'from':'gallery',
}
url = 'https://www.toutiao.com/search_content/?'+ urlencode(params)
md5(response.content).hexdigest() 獲取MD5值
os模塊
os.path.exists(path) //判斷當(dāng)前路徑是否存在
os.mkdir(path) //創(chuàng)建目錄
request
requests.ConnectionError
//requests請(qǐng)求連接的錯(cuò)誤