I am using python and Beautiful soup to download & locally save the image embedded/uploaded in this post: https://gall.dcinside.com/mgallery/board/view/?id=irudagall&no=18886&page=2027
However, it seems the image file is not downloadable. This is what I have so far:
from bs4 import BeautifulSoup
from requests import get
from PIL import Image
headers = {
"Connection" : "keep-alive",
"Cache-Control" : "max-age=0",
"sec-ch-ua-mobile" : "?0",
"DNT" : "1",
"Upgrade-Insecure-Requests" : "1",
"User-Agent" : "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.93 Safari/537.36",
"Accept" : "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
"Sec-Fetch-Site" : "none",
"Sec-Fetch-Mode" : "navigate",
"Sec-Fetch-User" : "?1",
"Sec-Fetch-Dest" : "document",
"Accept-Encoding" : "gzip, deflate, br",
"Accept-Language" : "ko-KR,ko;q=0.9"
}
test_url = 'https://gall.dcinside.com/mgallery/board/view/?id=irudagall&no=18887&page=2027'
test_res = requests.get(test_url, headers=headers)
test_soup = BeautifulSoup(test_res.text, "lxml")
img_url = test_soup.find("ul", {"class": "appending_file"}).find("a")['href']
img = Image.open(requests.get(image_url, stream = True).raw)
img.save('image.jpg')
