gopup icon indicating copy to clipboard operation
gopup copied to clipboard

求教大佬百度搜索指数报错

Open xiezheyu opened this issue 4 years ago • 5 comments

使用百度搜索指数的接口,使用的样例的代码: index_df = gp.baidu_search_index(word="口罩", start_date='2020-01-01', end_date='2020-03-01', cookie=cookie) 提示如下错误: Traceback (most recent call last): File "<pyshell#10>", line 1, in index_df = gp.baidu_search_index(word="口罩", start_date='2020-01-01', end_date='2020-03-01', cookie=cookie) File "C:\Users\zeyu_\AppData\Local\Programs\Python\Python39\lib\site-packages\gopup\index\index_baidu.py", line 264, in baidu_search_index all_data = data["userIndexes"][0][type]["data"] TypeError: string indices must be integers 求大佬指点,谢谢!

xiezheyu avatar Mar 01 '21 11:03 xiezheyu

出现这个结果主要是百度指数对于这个关键词 这段时间内的查询是 “暂无数据”的;而且百度指数也不是很稳定,有时有数据有时没有,你可以直接登录百度看看是否有数据。我后面的版本会加上判断是否是“暂无数据”

justinzm avatar Mar 08 '21 03:03 justinzm

谢谢,我目前是用捕获异常来解决这个问题,查不到数据就跳过。

xiezheyu avatar Mar 08 '21 03:03 xiezheyu

谢谢,我目前是用捕获异常来解决这个问题,查不到数据就跳过。

你好,请问如何在大佬的程序包的基础上,添加代码捕获异常,我进行关键词的搜索时,有些也没有数据。

LeBronck avatar Jan 01 '22 06:01 LeBronck

这是来自QQ邮箱的假期自动回复邮件。您好!我已收到您的邮件,我将尽快给你回复。

xiezheyu avatar Jan 01 '22 06:01 xiezheyu

我很久不用这个程序了,具体我已经不记得了, 大致是在大佬的“index_baidu.py”文件中的对应位置加上捕获异常的代码。

xiezheyu avatar Jan 04 '22 13:01 xiezheyu