我有一个大字符串(来自网页的html代码)。制作一个包含在一个大字符串中的链接数组
现在的问题是如何解析图像的链接。
我想制作该网页中所有图像链接的数组。
我知道如何做到这一点我的java,但我不知道如何做解析字符串,并在shell中做字符串操作。我知道有很多技巧,我想这可以很容易完成。
到底我想是这样的
#!/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
谢谢您的答复,你救了我的挫折
'for url in“$ {LINKS [@]}”;做echo $ url; done'。但是,我认为你不会从试图在'bash'中解析HTML获得任何东西。 – chepner 2012-07-13 15:03:07