view raw
Ryan Ryan - 8 months ago 37
Python Question

How to download image from site with no clear extention?

I am trying to download an image from the site using python 3 and urllib.

The site does not display images in a standard .jpg fashion and i get an error.

import urllib.request
from bs4 import BeautifulSoup

with urllib.request.urlopen("") as url:
s =

soup = BeautifulSoup(s, 'html.parser')

img = soup.find("img")

except Exception as e:
print (e)

Some characters could not be decoded, and were replaced with REPLACEMENT CHARACTER.
expected string or bytes-like object

Can someone please why i am getting this error and how to get the images to my computer.


BeautifulSoup is library for html/xml parsing. On this url you receive image already, so what are you trying to parse? This works ok: urllib.request.urlretrieve("" ,"C:\art.jpg")