Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

356
Vistas
Web Scraper using Python to download .png Images from .html webpage located on my C:/ drive locally to local folder

I'm working on a python script that imports beautiful soup, requests, and urllib.request APIs to fetch images from the address https://www.example.com/image.jpg and it works OK, listing them in my documents folder well numbered.

I have tried varies methods listed here but none seem to have helped, on google the solution were revolving around getting tags.

The question is how to script it to fetch images from my example.html sitting on my C:/ drive using the mentioned python script, where the browser am using is Opera and the HTML URL is file:///C:/Users/folder/folder/Desktop/folder/example.html, on the web address bar.

Here is the python script,

from bs4 import BeautifulSoup
import urllib.request
import requests

    # setting URL destination 
    url = "file:///C:/Users/folder/folder/Desktop/folder/example.html"
    
    # retrieving HTML payload from the website
    response = requests.get(url)
    
    # using BeautifulSoup to parse the response object
    soup = BeautifulSoup(response.content, "html.parser")
    
    # finding Post images in the soup
    images = soup.find_all("png", attrs={"alt":"Post image"})
    
    # downloading images
    number = 0
    for image in images:
        print(image["src"])
        image_src = image["src"]
        urllib.request.urlretrieve(image_src, str(number))
        number += 1
about 4 years ago · Juan Pablo Isaza
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda