nondanee/weiboPicDownloader

出现错误KeyError: 'cardlistInfo'

Closed this issue · 5 comments

kybom commented

用UID文件下载,其中一个UID出现如下错误

7/377 Tue May  1 22:57:03 2018
BEJ48-李烨 6206250993
Traceback (most recent call last):
  File "weiboPicDownloader.py", line 264, in <module>
    urls = get_urls(uid,args.video)
  File "weiboPicDownloader.py", line 171, in get_urls
    if total == -1: total = json_data["data"]["cardlistInfo"]["total"]
KeyError: 'cardlistInfo'

commit:

commit 113c8ead9157f5c0d388c3b07ba9f5f58c38e1fc
Author: nondanee <iminezn5656@outlook.com>
Date:   Mon Apr 30 14:29:16 2018 +0800

    optimization: empty sequences(explicit is better than implicit)

已经修复了,还是要解释一下
其实是再前一次commit导致的

commit c5be79f447d8a7ba2f361e699864dc82b68f1dfc
Author: nondanee <iminezn5656@outlook.com>
Date:   Thu Apr 19 01:00:26 2018 +0800

    optimization: use a formal way (ANSI escape sequences) to clear previous console line, change logic of image url query loop

当时改了退出循环的条件:

每页固定长度 * 页数 >= 总数 则退出

有想到总数为0的问题,所以初值是-1
但没意识到总数0的问题会获取不到。。。
本来是加个条件就好了

然而测试发现有用户的总数计数和实际发得微博数严重不符(62>49)

1/1 Wed May 02 00:04:40 2018
姬关枪啊 1651926050
finish analysis 62/49
practically get 62 weibos, 4 pictures
all tasks done 4/4(100%)
successfull 4, failed 0, total 4
------------------------------
bye bye

于是退回旧逻辑了,当然也可能会误伤
比如突然99页返回空,但其实100页,101页...还有数据,那只就会循环到99页为止

接口太神奇😢(带cookie请求更神奇)

kybom commented

又出现了这个错误:

36/441 Thu Jan 24 19:23:33 2019
SHY48-周佳怡 5167477072
Traceback (most recent call last):
  File ".\weiboPicDownloader.py", line 244, in <module>
    urls = get_resources(uid, args.video)
  File ".\weiboPicDownloader.py", line 165, in get_resources
    if total == sys.maxsize: total = json_data['data']['cardlistInfo']['total']
KeyError: 'cardlistInfo'

能不能跳过这个异常,继续下面的任务?

kybom commented

@nondanee 这个问题有什么解决办法

今天修了啊 😯

kybom commented

哦,好的,我试试。因为没看到log里有说明