format的迷惑行为

源码客栈 其他问答 1

回复

共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已经被封了,我这没事

    0条评论

发表回复

登录后才能评论