【发布时间】:2021-07-04 09:25:52
【问题描述】:
我需要你的帮助。我正在开发一个电报机器人,它将亚马逊的所有销售额发送给我。 它运行良好,但此功能无法正常运行。我总是遇到同样的错误,但是会阻止脚本
imgs_str = img_div.img.get('data-a-dynamic-image') # 一个Json格式的字符串 AttributeError: 'NoneType' 对象没有属性 '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
我仍然不明白如何解决这个问题。 谢谢大家!
【问题讨论】:
标签: python-3.x beautifulsoup telepot