I am trying to make a simple program which gets all the image addresses on a website, and then downloads them into a folder. The problem is that I get a 403 Error. I have been trying to fix it for over and hour and desperately need help. Here is my code:
import urllib.request
import requests
from bs4 import BeautifulSoup
url = 'https://www.webtoons.com/en/slice-of-life/how-to-love/ep-100-happy-ending-last-episode/viewer?title_no=472&episode_no=100'
data = requests.get(url)
code = BeautifulSoup(data.text, 'html.parser')
photos = []
def dl_jpg(url, filePath, fileName):
fullPath = filePath + fileName + '.jpg'
urllib.request.urlretrieve(url, fullPath)
for img in code.find('div', id='_imageList'):
pic = str(img)[43:147]
photos.append(str(pic))
for photo in photos:
if photo == '':
photos.remove(photo)
for photo in photos[0:-4]:
dl_jpg(photo, 'images/', 'img')