dataabc / weibo-crawler

新浪微博爬虫,用python爬取新浪微博数据,并下载微博图片和微博视频
3.25k stars 739 forks source link

random.shuffle(user_id_list) 这个修改,如果 user_id_list 是文件路径的话,会导致报错 #378

Open chjuheng opened 1 year ago

chjuheng commented 1 year ago

如题

dataabc commented 1 year ago

感谢建议。 我现在不方便调试,可能要过一段时间才能修复。您也可以自己修改代码,然后再pull request提交修改。具体就是加个判断,检测user_id_list是否是list,然后再shuffle。这样您还能成为本项目的contributor。这不是强制的,您已经帮助发现了代码的不足,是否帮助修复都非常感谢。

lisicheng1997 commented 1 year ago

我说为什么这次我文件路径导入失败一直解决不了,一直提示这个

lisicheng1997 commented 1 year ago
    if isinstance(user_id_list, list):
        random.shuffle(user_id_list)
    else:
        with open(user_id_list, 'r') as f:
            user_id_list = [line.strip() for line in f]
        random.shuffle(user_id_list)

按照作者思路,将这部分内容替换掉89行代码,解决问题

lisicheng1997 commented 1 year ago

不太会github这个pr不知道上传成功了不,希望大家能看到吧