raise HTTPError(req.full_url, code, msg, hdrs, fp) urllib.error.HTTPError: HTTP Error 403: Forbidden

Lavish Programmer

Manga (Japanese comics) aren't available in pdf but in raw images, so I created a tool that would automatically download the photos.

Here's my code

import requests
import urllib.request
from bs4 import BeautifulSoup

responsePage = input("Enter URL: ")
response = requests.get(responsePage)

soup = BeautifulSoup(response.text, 'html.parser')
images = soup.findAll('img')

image_name = 0

for img in images[1:-1]:
    image_name += 1
    url = img['src']
    full_name = str(image_name) + '.jpg'
    print(response.headers)
    resource_image = urllib.request.urlretrieve(url, full_name)
    print(full_name + " Saved!")

The error I receive is:

urllib.error.HTTPError: HTTP Error 403: Forbidden

Any suggestions on how I can solve this problem? Help would be appreciated.

Gahan
import requests
from bs4 import BeautifulSoup
import os

def download_image(url, path):
    r = requests.get(url, stream=True)
    if r.status_code == 200:
        with open(path, 'wb') as f:
            for chunk in r:
                f.write(chunk)

URL = "https://manganelo.com/chapter/read_detective_conan_manga_online_free/chapter_10"
r = requests.get(URL)

soup = BeautifulSoup(r.text, 'html.parser')
images = soup.findAll('img')
for i in images:
    url = i.attrs["src"]
    os.makedirs(url.split('/')[-2], exist_ok=True)
    download_image(url, os.path.join(url.split('/')[-2], url.split('/')[-1]))

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

HTTPError: HTTP Error 403: Forbidden on Google Colab

urllib2.HTTPError: HTTP Error 403: Forbidden

urllib2.HTTPError: HTTP Error 403: Forbidden

Again urllib.error.HTTPError: HTTP Error 400: Bad Request

download image from url using python urllib but receiving HTTP Error 403: Forbidden

HTTP Error 403: Forbidden with urlretrieve

Python: urllib.error.HTTPError: HTTP Error 404: Not Found

HTTP Error 403: Forbidden while downloading file using urllib

urllib.error.HTTPError: HTTP Error 503: Service Unavailable python

urllib.error.HTTPError: HTTP Error 502: Bad Gateway PYTHON

bokeh sample data download fail with 'HTTPError: HTTP Error 403: Forbidden'

Beautiful Soup - urllib.error.HTTPError: HTTP Error 403: Forbidden

urllib.error.HTTPError: HTTP Error 403: Forbidden for urlretrieve

How to solve this Error ??? raise HTTPError(req.full_url, code, msg, hdrs, fp) HTTPError: Forbidden

urllib2 Error 403: Forbidden

gTTS HTTPError: 403 Client Error: Forbidden for url

Python urllib.error.HTTPError: HTTP Error 404: Not Found

urllib.error.HTTPError: HTTP Error 404: Not Found

Python 3.6.2 url.request.urlopen() urllib.error.HTTPError: HTTP Error 403: Forbidden

torchvision MNIST HTTPError: HTTP Error 403: Forbidden

Pytube error: urllib.error.HTTPError: HTTP Error 404: Not Found

Web Scraping getting error (HTTP Error 403: Forbidden) using urllib

Pytube : urllib.error.HTTPError: HTTP Error 410: Gone

urllib.error.HTTPError: HTTP Error 403: Forbidden in my web scrapping

urllib.error.HTTPError: HTTP Error 403: Forbidden with urllib.requests

urllib.error.HTTPError: HTTP Error 404: Not Found yfinance library

JSON from webpage into Python script: urllib.error.HTTPError: HTTP Error 403: Forbidden

python urllib.request http error 403: forbidden

HTTPError: 403 Client Error: Forbidden for url via Office365-REST-Python-Client