Recently I read a translation version of a Quora Q&A in which people are talking about how the programmers use computer to serve their own life.
The translation version is: 看程序员是如何把自动化做到极致的!
And the initial Quora post is: As a programmer, what tasks have you automated to make your everyday life easier?
One engineer just mentioned he wrote a small program to download Bing background images everyday automatically by the computer. The images, which would be a new one everyday, are all great photographs token all over the world.
后来再尝试代码发现不行了。。。 2017.10
Recently, I start learning and using Python in my work. And I heard a lot about Python’s fantastic functionality in collecting data from the Internet.
So I think maybe I could do this as well.
A post on 知乎 can be a good intro on Python reptile for us beginners - 如何入门 Python 爬虫?.
See the Pictures
Now the program has been run for 3 times.
Following are the results!
Look great! Right?
Now let’s start to do the job!
First, Get the Picture
This time, I use urllib.request
module.
|
|
Next, Ask PC to do Everyday Job
crontab
I searched and people say crontab
could solve the problem and it’s already in Linux os.
Syntax is as below:
|
|
Below is the syntax of crontab
.
However, I failed…
Now I think maybe because I didn’t specify the user name.
python-crontab
Then I just find a python package called crontab
which can do the same job.
Use pip install python-crontab
to complete the installation.
|
|
After setting a crontab task, we can use crontab -l
in Terminal to check.
Now we can see
which means 09:45 everyday, python3
would run bing_img.py
.
If the computer is power off, the crontab
will not work.
Next Step
Maybe in next step I can collect the description for the image everyday because I can tell no information only by looking at the beautiful pictures.
Or I could try other interesting tasks ;P