Issue
I'm trying to use a web scrapper that gets images from a site.
However, my methods cause a severe drop in quality.
I'm trying to scrape the images from this site.
I have tried to download the image and use the image link I got from the href
tag. Both of these attempts cause a considerable drop in image quality. I am now considering taking a screenshot and cropping the image, however, I feel like this would be a roundabout way to do it. Does anyone know of a method to get around the quality drop? or any useful libraries maybe?
(edit) The easiest way seems to be to download the images themselves using a combination of request and web frameworks; might pursue this but I'm going to give it a little more time to stew. Does anyone know of a way to use the images without outright downloading them?
Solution
Manually getting the data through requests and writing it to a file of the same extension should work.
import requests
url = "https://img.ltwebstatic.com/images3_pi/2023/04/22/1682132328cfa167169f129c340da4fc854d5587b4_thumbnail_600x.jpg"
img_data = requests.get(url).content
with open('image.jpg', 'wb') as f:
f.write(img_data)
Answered By - pineconee
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.