首页 > 解决方案 > 在dict中重新迭代for循环

问题描述

每次服务器禁止我的 ip(60 秒)时,getid() 方法都会给出一个非类型错误。我希望每次遇到错误时都重复循环实例,以免错过任何项目。我如何做到这一点?

for t in soup.find_all("div",{"class":"vItem Normal"}):
        try:
            if(t["data-exterior"]=="Not Available"):
                continue
            name.append(t["data-hashname"])
            id_parse=requests.get(f"http://steamcommunity.com/market/listings/730/{name[-1]}")
            item_id=getid(id_parse.text)
            skin_ids[name[-1]]=item_id
            sleep(3)
        except:
            sleep(60)
            #i want to reiterate now

标签: python-3.x

解决方案


推荐阅读