爬取听过喜马拉雅的节目信息
import requests
import json
headers = {
'User-Agent':'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3724.8 Safari/537.36',
'cookie':'1&remember_me=y; 1&_token=48608286&950A40C5440841309AEDD077374D613BNdV2663A48A7B60DE4759335E18868A57F856BEB09CA03FD9665CC36143F7B89616; _xmLog=xm_1560403610866_jwu80ruaoesmql; Hm_lvt_4a7d8ec50cfd6af753c4f8aee3425070=1560402949,1560407864; Hm_lpvt_4a7d8ec50cfd6af753c4f8aee3425070=1560407864; x_xmly_traffic=utm_source%253A%2526utm_medium%253A%2526utm_campaign%253A%2526utm_content%253A%2526utm_term%253A%2526utm_from%253A; device_id=xm_1560409290665_jwubeiehi7zbgr'
}
url ='https://www.ximalaya.com/revision/my/getListened'
def get_info(url,page):
res = requests.get(url,headers=headers)
json_data = json.loads(res.text)
earliers = json_data['data']['earlier']
for earlierin earliers:
albumName = earlier['albumName']
createAtStr = earlier['createAtStr']
trackTitle = earlier['trackTitle']
print(albumName,createAtStr,trackTitle)
get_info(url,1)