Python Forum
HTTPError: Forbidden when try download image
Thread Rating:
  • 2 Vote(s) - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
HTTPError: Forbidden when try download image
#1
i want to download picture on wallhaven.cc and i can get picture url but image is not download its give an error ; 

my code is ;

import urllib.request
from bs4 import BeautifulSoup

imdbUrl="htt"+"ps:"+"//alpha.wallhaven.cc"+"/random?page=4"
r=requests.get(imdbUrl)

soup=BeautifulSoup(r.content,"html.parser")

kelimeler=soup.find_all("img",{"class":"lazyload"})

say=0
for i in kelimeler:
    say +=1
    url=str(i['data-src'])
    url=url.replace("alpha","wallpapers")
    url=url.replace("/thumb/small/th-","/full/wallhaven-")
    url=url.replace("https","http")
    yeniad=str(say)+".jpg"
    url=url.strip()
    print(url)
    urllib.request.urlretrieve(url,yeniad)
but its give an error like this ; 
Error:
HTTPError: Forbidden
Reply


Messages In This Thread
HTTPError: Forbidden when try download image - by b33g33 - Jan-20-2017, 04:53 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  403 Forbidden Error Evil_Patrick 1 4,461 Jun-20-2020, 02:19 PM
Last Post: snippsat
  urllib.error.HTTPError: HTTP Error 404: Not Found ckkkkk 4 8,782 Mar-03-2020, 11:30 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020