Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

348
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!