Strip url from a web pages
Monday, 16. July 2007, 06:16:00
Để lọc ra các url link để download trong một trang web, có rất nhiều cách, dưới này chỉ là một cách nhanh gọn bằng 1 script awk nho nhỏ từ : http://www.gnu.org/software/gawk/manual/gawkinet/html_node/WEBGRAB.html đã được mod lại xíu :
với target.html là file đã save về local, muốn dùng direct link thì cần 1 script awk nho nhỏ nữa, nhưng chắc không cần thiết.
BEGIN { RS = "http://[#%&\\+\\-\\./0-9\\:;\\?A-Z_a-z\\~]*" }
RT != "" { command = ("wget " RT \)
print command
}
gawk -f getlink.awk target.html > down.sh
với target.html là file đã save về local, muốn dùng direct link thì cần 1 script awk nho nhỏ nữa, nhưng chắc không cần thiết.








pclouds # 16. July 2007, 14:51
grep 'href="' target.html|sed 's,.*href="\([^"]*\)".*,\1,g' (change href= to src= if you are going to grab images)
it's not perfect (won't work with href=blah without quotes) but simple enough to type it by hand
oh and append the following to wget them all
grep ...|sed ...|while read i;do wget "$i";done
Lu cát # 16. July 2007, 15:28