Welcome folks today in this blog post we will be downloading bing api
wallpaper web scraping in python. All the full source code of the application is given below.
Get Started
In order to get started you need to install the following library using the pip
command as shown below
pip install bs4
pip install urllib
pip install requests
After installing all these libraries you need to make an app.py
file and copy paste the following code
app.py
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
from bs4 import BeautifulSoup from datetime import datetime import requests import urllib.request res = requests.get('https://bing.wallpaper.pics/') soup = BeautifulSoup(res.text,"lxml") image_box = soup.find("a",{"class" : "cursor_zoom"}) image = image_box.find('img') link = image['src'] #print(link) #urllib.request.urlretrieve(link,'_new.jpg_') filename = datetime.now().strftime('%d-%m-%y') urllib.request.urlretrieve(link,filename +".png") |
Now if you execute the python
script by typing the below command as shown below
python app.py