Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to get pictures by shell script

2025-03-30 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/01 Report--

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

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 240

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report