Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

359
Visualizações
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 à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda