我需要你的帮助。我正在开发一个电报机器人,它将亚马逊的所有销售额发送给我。它运行良好,但此功能无法正常运行。我总是遇到同样的错误,但是会阻止脚本
imgs_str = img_div.img.get('data-a-dynamic-image') # 一个 Json 格式的字符串 AttributeError: 'NoneType' object has no attribute 'img'
def take_image(soup):
img_div = soup.find(id="imgTagWrapperId")
imgs_str = img_div.img.get('data-a-dynamic-image') # a string in Json format
# convert to a dictionary
imgs_dict = json.loads(imgs_str)
#each key in the dictionary is a link of an image, and the value shows the size (print all the dictionay to inspect)
num_element = 0
first_link = list(imgs_dict.keys())[num_element]
return first_link
我仍然不明白如何解决这个问题。谢谢大家!