Home
Categories
WIKI
Topic
User
LANGUAGE:
中文
English
抓取bing首页图片当壁纸shell脚本
Experiences and Insight
752
views ·
1
replies ·
To
floor
Go
qq420100523
deepin
2018-09-16 22:00
Author
本帖最后由 qq420100523 于 2018-9-16 16:16 编辑
#!/bin/bash
# picture directory
PICTURE_DIR=~/Pictures/bing_wallpapers/
# Create picture directory if it doesn't already exist
mkdir -p "${PICTURE_DIR}"
# Base Bing URL
bing="www.bing.com"
# default index
idx=0
# Max Number of images
n=8
# What day to start from. 0 is the current day,1 the previous day, etc...
day="&idx=$idx"
# Number of images to get
# May change this script later to get more images and rotate between them
number="&n=$n"
#Set market, other options are:
#"&mkt=zh-CN"
#"&mkt=ja-JP"
#"&mkt=en-AU"
#"&mkt=en-UK"
#"&mkt=de-DE"
#"&mkt=en-NZ"
#"&mkt=en-CA"
#"&mkt=en-US"
market="&mkt=zh-CN"
# Parse bing.com and acquire picture URL(s)
# Get the json file
json=$(curl -sL "http://$bing/HPImageArchive.aspx?format=js$day$number$market" )
#echo $json
# urls=$(echo $json | grep -Po '"url":".*?"' | sed "s/\"//g" | awk -F "[:]" '/url/{print$2}')
urls=$(echo $json | grep -Po '"url":".*?"' | sed "s/\"//g" | cut -d : -f 2)
urls=(${urls/// })
# Download the pictures
for img_url in "${urls[@]}"; do
img_name=$(echo "$img_url"|sed -e "s/.*\/\(.*\)/\1/")
if [ ! -f "$PICTURE_DIR/$img_name" ]; then
printf "Downloading: $img_name...\n"
curl -s -Lo "$PICTURE_DIR/$img_name" "$bing/$img_url"
else
printf "Skipping: $img_name...\n"
fi
done
Copy the Code
改权限运行:
chmod u+x getBingWallpapers.sh
./getBingWallpapers.sh
Copy the Code
搭配自动切换壁纸shell脚本一起食用,口味更佳!
自动切换壁纸shell脚本:https://bbs.deepin.org/post/168824#=1##pid516428
Reply
Like 0
Favorite
View the author
All Replies
addhapp
deepin
2018-09-16 22:24
#1
给力,收藏了
Reply
Like 0
View the author
Please
sign
in first
Featured Collection
Change
[Tutorial] deepin25 WSL Offline Installation Guide
UOS AI 2.8 Released! Three New Intelligent Agents & Major Evolution
Solid Q&A | deepin 25 Common Questions – The Immutable System Edition
New Thread
Popular Ranking
Change
【Enhanced Repo】Better Deepin Repo is released
Update driver for my computer
Popular Events
More
改权限运行:
自动切换壁纸shell脚本:https://bbs.deepin.org/post/168824#=1##pid516428