A python web scraping project which automatically downloads a random wallpaper and sets it on your desktop depending upon a few inputs.
I made this project in order to learn web scraping. I have used requests and beautiful soup 4 to scrap a webpage and download wallpapers from there. When you run the main.py
, you have two choices - set any random wallpaper or choose a category and then set the random wallpaper from that category.
- Open your terminal and enter
python main.py
, if you have only python=>3 installed, else usepython3 main.py
- You will be asked for either entering 1 or 2.
- If you choose 1
- The program will download a random wallpaper and set it as your destop wallpaper
- If you choose 2
- You will be first asked to choose a category. Enter the index accordingly and WallE will set your desktop wallpaper.
Basically, i have broken my entire project into different modules. Let's go by them one by one:
-
main.py
The main python file which calls other functions from different modules. You just need to run this one and chill. -
- mainUrl: The main url of the website,as i have used the main url of the website again and again.
- file_url: The file path where the wallpaper gets stored. By default, images gets stored in 'wallpapers' folder in the project's directory. You can change it by changing variable
dirName
. I have usedos.system
, because it will make WallE adjust file namings depending on the os you are using.
-
Image_downloader.py
Downloads the wallpaper using the given 'image url' and saves indirName
-
LastPageCalculator.py
As i am using random wallpapers, so i am usingrandom.randint()
python function. As it needs an upper bound, i am usingcalcLastpage()
which find the last page for the website. -
Categories.py
It scraps the categories of wallpapers and returns the url of the chosen category's page. -
SetWallPaper.py
It uses the gnome commandgsettings set org.gnome.desktop.background picture-uri fileurl
to set the wallpaper from the directory specified. -
GetWallpaper.py
The heart of the project which uses 'image downloader', 'SetWallpaper' modules to parse the main pages, get the image links, select a random image, download it, save it, and finally set the wallpaper.
- requests
- BeautifulSoup4
Run sudo pip install -r requirements.txt
from your terminal to install the dependencies