Home > OS >  Unable to Get Image Using urllib3
Unable to Get Image Using urllib3

Time:01-08

Wondering what I'm missing... urllib3 request isnt returning...

import urllib3

url = "https://www.mouser.com/images/adi/sm/ITP_ADI_SOT-23-6_05-08-1636_t.jpg"

http = urllib3.PoolManager()
response = http.request('GET', url)
print(response.status)

Stepped through it in debug and this is what I see:

Debug snap

CodePudding user response:

you need to specify the headers.

import urllib3

url = "https://www.mouser.com/images/adi/sm/ITP_ADI_SOT-23-6_05-08-1636_t.jpg"

http = urllib3.PoolManager(headers={'User-Agent': 'Mozilla/5.0'})
response = http.request('GET', url)

print(response.status)
  • Related