嘿伙计们,我正在尝试使用 BeautifulSoup 获取图像,但是这样做时出现错误:
这是我的代码:
imgUrl = "https://www.residentadvisor.net/images/events/flyer/2017/7/no-0713-986042-front.jpg"
try:
urlretrieve(imgUrl, "testPhytonImg.jpg")
except FileNotFoundError as err:
print("something wrong with local path")
print(err) # something wrong with local path
except HTTPError as err:
print("something wrong with url")
print(err) # something wrong with url
这是我得到的错误:
HTTP Error 403: Forbidden
为什么我得到这个?对图像的访问是否因为我所做的事情而被阻止,或者有其他方法吗?