Get the App
SLTechnology News&Howtos  ›  Servers  › 

How to get pictures by shell script

Shulou Source: shulou.com Published: 2022-06-01 02:59:07 09月22日 Update

This article mainly introduces the shell script how to achieve access to pictures, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor with you to understand.

The shell script implements the acquisition of pictures.

#! / usr/bin/bash

. / etc/init.d/functions

Function check () {

Time= `date "+% F% X" `

Echo "current time: $time"

Ip=$ (ip a | grep inet | grep "scope global dynamic" | awk-F "/"'{print $1}'| awk'{print $2}')

Ping-W1-C1 www.baidu.com & > / dev/null

If [[$?-ne 0]]; then

Echo_failure | | echo "Network exception, please check"

Else

Echo_success & & echo "Network normal current IP:$ip"

Fi

Yum repolist & > / dev/null

If [[$?-ne 0]]; then

Echo_failure | | echo "yum exception, please check"

Fi

}

Function down () {

Yum install-y wget & > / dev/null

W = `echo "$1" | tr-d'\ n'| od-An-tx1 | tr''% `

Data=$ (curl-s "https://image.baidu.com/search/index?tn=baiduimage&word=$w")

Echo $data | grep-P-o "https://ss.*?.jpg" | sort-n-r | uniq > > $2/url2.txt

Aplasy 0

While read line

Do

Sleep 1

Code=$ (curl-I "$line" 2 > / dev/null)

If [${code:9:3}-eq 200]; then

Wget-O $2Compact 1 ${a} .jpg $line & > / dev/null

Echo "download completed $line"

Else

Echo "invalid Resource $line"

Fi

Let axiom +

Done

Tags: Pictures programs scripts resources being articles web inspection happiness you and me function time environment programming later China design input politeness value Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MariaDB Docker Shulou Information macOS