format的迷惑行为
其他问答
1
-
import requests import time headers = { 'user-agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_13_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/76.0.3809.132 Safari/537.36', 'referer': 'http://movie.mtime.com/' } for num in range(1,4): params = { "tt": "{}".format(int(time.time() * 1000)), "movieId": "251525", "pageIndex": "{}".format(num), #为什么这个地方直接用num填进去会报错 "pageSize": "50", "orderType": "1" } res = requests.get( 'http://front-gateway.mtime.com/library/movie/comment.api', headers=headers, params=params) resJson = res.json() print("resJson:", resJson) if resJson: res = resJson['data']['list'] for i in res: print('用户:', i['nickname']) print('评论:', i['content']) time.sleep(1)
改成这个,应该是res.json()的结果是None, 可能你的IP已经被封了,我这没事
发表回复