電腦視覺經典論文集&此資源批量分類下載的Python程式

來源:互聯網
上載者:User

該資源為德州大學奧斯丁分校電腦視覺領域文獻閱讀課資源,此實驗室在cv領域想必大家都知道的,該網頁論文好多,使用迅雷的批量下載頁不好使啊,自己用python寫了一個多線程批量分類下載的程式,將論文下載到不同的檔案夾並根據類別命名此檔案夾,下載速度在本人這裡最快為6M/S,建議下載前先翻牆(否則有些國外連結會受限制而下不到其網站資源),最好晚上睡覺前運行程式,然後就可以直接睡覺去啦~
全部論文下載下來大小為600M+,注意保證硬碟有足夠空間哦~


下面將資源分享給大家!
資源網址為:http://www.cs.utexas.edu/~cv-fall2012/schedule.html ,Python源碼貼在下面,注意試用前請保證安裝了BeautifulSoup庫


# -*- coding: utf-8 -*-"""Created on Wed Jan 09 10:33:29 2013@author: lanbing510 lxs"""from bs4 import BeautifulSoupimport reimport urllibimport urlparseimport osimport sysimport threading import tracebackfull_url='http://www.cs.utexas.edu/~cv-fall2012/schedule.html'response=urllib.urlopen(full_url)soup = BeautifulSoup(response.read())#import codecs, sys#old=sys.stdout#sys.stdout = codecs.lookup('utf-8')[-1]( sys.stdout)#print soup.prettify()down_count=0def downLoad(url,path):    def cbk(a, b, c):                """回呼函數         @a: 已經下載的資料區塊         @b: 資料區塊的大小         @c: 遠程檔案的大小         """        per = 100.0 * a * b / c          if per>100:              per=100              #print '%.2f%%' % per      urllib.urlretrieve(url,path,cbk)    global down_count    down_count+=1;    print path.split("\\")[-1],'has download'    print 'have finished %d files ^_^' % down_count    """測試downLoad函數用"""#url='http://www.sina.com.cn'  #local='d:\\sina.html'  #downLoad(url,local)    def main():    #f=open('path.txt','w+')#測試用    threads=[]#線程池    local_path='.\\lan\\'#根目錄    c1_path=''#一級目錄    c2_path=''#二級目錄    count=0;c=0;#for test    for sibling in soup.tr.next_siblings:        if sibling!='\n':            #count+=1            #print "[%d]: %s" %(count,repr(sibling))            #print type(sibling)            sibstr=repr(sibling)            if (re.search('rgb\(204, 204, 255\)',sibstr))!=None:                """注意括弧的正則"""                #c+=1                print sibling.a['name']                c1_path=local_path+repr(sibling.a['name'])                if os.path.exists(c1_path)==False:                    os.mkdir(c1_path)                #continue            slist=sibling.find_all('a')            if slist!=[]:                try :                    c2_path=c1_path+'\\'+repr(slist[0]['name'])                except KeyError:                    continue                #print c2_path                c2_path=c1_path+'\\'+repr(slist[0]['name'])                if os.path.exists(c2_path)==False:                    os.mkdir(c2_path)                                                    for li in slist[1:]:                    temp_url=li.get('href')                    count+=1                    if temp_url!=None:                         patt='http.+|ftp.+|www.+'                        if re.match(patt,temp_url)==None:                            temp_url=r'http://www.cs.utexas.edu/~cv-fall2012/'+temp_url#處理本伺服器上的檔案                        url_split_temp=temp_url.split('/')                        url_sp=url_split_temp[-1]if url_split_temp[-1]!='' else (url_split_temp[-2]+'.html')                        patt2='\.pdf$|\.html$|\.ppt$|\.doc$|\.docx$|\.pptx$|\.rar$|\.htm$|\.gz$|\.xml$'                        if re.search(patt2,url_sp)==None:                            url_sp=url_sp+'.html'                        temp_path=c2_path+'\\'+url_sp                    else:continue                   # print >>f,temp_url,'\n'                   # print >>f,temp_path,'\n'                #print count    #print 'c=',c                    t=threading.Thread(target=downLoad,args=(temp_url,temp_path))                    threads.append(t)                    t.start()    #f.close()if __name__=='__main__':        fe=open("error.txt",'w')#except的資訊    sys.stderr=fe    try:        main()    finally:        fe.close()        sys.stderr=sys.stdout


聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.