萬盛學電腦網

 萬盛學電腦網 >> 服務器教程 >> Linux抓取批量下載地址

Linux抓取批量下載地址

視頻網站在線播放列表如下圖所示:

Linux抓取批量下載地址 三聯 查看源代碼:  
<div class="fj1"><span>第1集</span>
<a href="/eschool/video/autohtml/310/261/0.shtml" target="_blank">1 C++簡介</a></div>
<div class="fj1"><span>第2集</span>
<a href="/eschool/video/autohtml/310/261/1.shtml" target="_blank">2 C++的發展過程</a></div>
<div class="fj1"><span>第3集</span>
<a href="/eschool/video/autohtml/310/261/2.shtml" target="_blank">3 C與C++的區別</a></div>
<div class="fj1"><span>第4集</span>
<a href="/eschool/video/autohtml/310/261/3.shtml" target="_blank">4 學習C++之前要先學C嗎?</a></div>
<div class="fj1"><span>第5集</span>
<a href="/eschool/video/autohtml/310/261/4.shtml" target="_blank">5 C++與其他語言的區別</a></div>
<div class="fj1"><span>第6集</span>
<a href="/eschool/video/autohtml/310/261/5.shtml" target="_blank">6 C++版本及安裝問題</a></div>
<div class="fj1"><span>第7集</span>
<a href="/eschool/video/autohtml/310/261/6.shtml" target="_blank">7 VS2005編譯器</a></div>
<div class="fj1"><span>第1集</span>
<a href="/eschool/video/autohtml/310/281/0.shtml" target="_blank">1 簡單的屏幕輸出小程序</a></div>
<div class="fj1"><span>第2集</span>
<a href="/eschool/video/autohtml/310/281/1.shtml" target="_blank">2 輸出語句的使用</a></div>
<div class="fj1"><span>第3集</span>
<a href="/eschool/video/autohtml/310/281/2.shtml" target="_blank">3 std::是什麼?</a></div>
<div class="fj1"><span>第4集</span>
<a href="/eschool/video/autohtml/310/281/3.shtml"target="_blank">4iostream與iostream.h區別</a></div>
<div class="fj1"><span>第5集</span>
<a href="/eschool/video/autohtml/310/281/4.shtml" target="_blank">5 重名沖突</a></div>
<div class="fj1"><span>第6集</span>
<a href="/eschool/video/autohtml/310/281/5.shtml" target="_blank">6 注釋</a></div>
<div class="fj1"><span>第1集</span>
<a href="/eschool/video/autohtml/310/301/0.shtml" target="_blank">1 函數演示</a></div>
<div class="fj1"><span>第2集</span>
<a href="/eschool/video/autohtml/310/301/1.shtml" target="_blank">2 函數的傳參</a></div>
<div class="fj1"><span>第3集</span>
<a href="/eschool/video/autohtml/310/301/2.shtml"target="_blank">3函數的返回值、參數與變量.swf</a></div>
<div class="fj1"><span>第4集</span>
<a href="/eschool/video/autohtml/310/301/3.shtml" target="_blank">4 函數的聲明與定義</a></div>
<div class="fj1"><span>第5集</span>
<a href="/eschool/video/autohtml/310/301/4.shtml" target="_blank">5 局部變量</a></div>
<div class="fj1"><span>第6集</span>
<a href="/eschool/video/autohtml/310/301/5.shtml" target="_blank">6 全局變量</a></div>
<div class="fj1"><span>第1集</span>
<a href="/eschool/video/autohtml/310/302/0.shtml" target="_blank">1 C++數據類型</a></div>
<div class="fj1"><span>第2集</span>
<a href="/eschool/video/autohtml/310/302/1.shtml" target="_blank">2 什麼是變量</a></div>
<div class="fj1"><span>第3集</span>
<a href="/eschool/video/autohtml/310/302/2.shtml" target="_blank">3變量及數據如何存儲在內存上</a></div>
<div class="fj1"><span>第4集</span>
<a href="/eschool/video/autohtml/310/302/3.shtml" target="_blank">4 布爾型</a></div>
<div class="fj1"><span>第5集</span>
<a href="/eschool/video/autohtml/310/302/4.shtml" target="_blank">5 字符型</a></div>
<div class="fj1"><span>第6集</span>
<a href="/eschool/video/autohtml/310/302/5.shtml" target="_blank">6 雙字節型</a></div>
<div class="fj1"><span>第7集</span>
<a href="/eschool/video/autohtml/310/302/6.shtml" target="_blank">7 整型概述</a></div>
<div class="fj1"><span>第8集</span>
<a href="/eschool/video/autohtml/310/302/7.shtml" target="_blank">8 為什麼使用補碼</a></div>
<div class="fj1"><span>第9集</span>
<a href="/eschool/video/autohtml/310/302/8.shtml" target="_blank">9 整型變量的定義</a></div>
<div class="fj1"><span>第10集</span>
<a href="/eschool/video/autohtml/310/302/9.shtml" target="_blank">10 浮點型變量</a></div>
<div class="fj1"><span>第11集</span>
<a href="/eschool/video/autohtml/310/302/10.shtml" target="_blank">11 常量</a></div>

我們現在開始抓取網址:

curl http://www.enet.com.cn/eschool/video/autohtml/310/281/0.shtml
 | sed -n 's/"/n/gp'  | grep ^/eschool/video/autohtml/ > down

結果如下:

然後我們將網址補齊:  
sed 's///http://www.enet.com.cn//' down  > downdown  


 

最後我們調用shell腳本  
#!/bin/bash  
for line in `cat downdown`  
do  
curl $line | sed -n 's/"/n/gp' | grep ^http://images.enet.com.cn/eschool/c++/ >> download.txt  
done  


 

最後抓取的下載地址如下:   現在你可以用迅雷進行批量下載了!
copyright © 萬盛學電腦網 all rights reserved