Skip to content
Advertisement

Python request.get error on Wikipedia image URL

Requests.get() does not seem to be returning the expected bytes for Wikipedia image URLs, such as https://upload.wikimedia.org/wikipedia/commons/0/05/20100726_Kalamitsi_Beach_Ionian_Sea_Lefkada_island_Greece.jpg:

JavaScript

Advertisement

Answer

Most websites block requests that come in without a valid browser as a User-Agent. Wikimedia is one such.

JavaScript

which will give you expected output

enter image description here

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement