大きな文字列 (Web ページの HTML コード) があります。
問題は、画像へのリンクを解析する方法です。
その Web ページ内の画像へのすべてのリンクの配列を作成したいと考えています。
Javaでこれを行う方法は知っていますが、シェルで文字列を解析して文字列操作を行う方法がわかりません。多くのトリックがあることは知っていますが、これは簡単にできると思います。
最終的に私はこのようなものを手に入れたい
#!/bin/bash
read BIG_STRING <<< $(curl some_web_page_with_links_to_images.com)
#parse the big string and fill the LINKS variable
# fill this with the links to image somewhow (.jpg and .png only)
#after the parsing the LINKS should look like this
LINKS=("www.asd.com/asd1.jpg" "www.asd.com/asd.jpg" "www.asd.com/asd2123.jpg")
#I need the parsing and to fill the LINKS variable with the links from the web page
# get length of an array
tLen=${#LINKS[@]}
for (( i=0; i<${tLen}; i++ ));
do
echo ${LINKS[$i]}
done
ありがとう、あなたは私に何日もの欲求不満を救ってくれました