Im trying to download images off a website but I keep getting getting this error:
HTTP Error 403: Forbidden
This is the function I created, to be able to do this:
def download_images(url,knife):
'''
download_images is a function which will extract pictures of the knives in csgo
url is the list of url which the images will be extracted from
images of 'knife' will be downloaded
'''
page = requests.get(url)
#Use beautifulsoup to extract the image urls
soup = BeautifulSoup(page.content, 'html.parser')
#Pull all image labels from the website with instances of img_alt
for img in soup.find_all('img', alt = True):
#Find the url and labels of the knives
if knife in img['alt']:
#Download the images with the correct labels
urllib.request.urlretrieve(img['src'],'{}.png'.format(img['alt']))