Sunday, March 13, 2016

Auto download images from any Web Site to local System

Below is the source to download the images from any site.
import requests
import urllib3
from bs4 import BeautifulSoup
html=requests.get('http://wallpaperswide.com/jessica_alba-desktop-wallpapers.html')
soup=BeautifulSoup(html.content)
images=[img for img in soup.find_all("img")]
print (images)
print ("Downloading the images from the site")
path=str(input("Please enter the path where you want to download"))
print (path)
path1=path.replace("\\","\\\\")
images_link=[each.get("src") for each in images]
print (images_link)
val=1
for each in images_link:
filename=each.split('/')[-1]
print("path1"+path1)
fullpath=path1 + "\\\\" +filename
print("fullpath"+fullpath)
response=requests.get(each)
if response.status_code==200:
f=open(fullpath,'wb')
f.write(response.content)
f.close()
print("file have been saved")



     

1 comment:

  1. Casino site ᐉ VIRGINIA 100% Deposit Match Bonus up to
    Online casinos accept players luckyclub.live from countries around the world. These online casinos accept players from Asia and beyond. No deposit free spins. Casino

    ReplyDelete