免费视频淫片aa毛片_日韩高清在线亚洲专区vr_日韩大片免费观看视频播放_亚洲欧美国产精品完整版

打開APP
userphoto
未登錄

開通VIP,暢享免費(fèi)電子書等14項(xiàng)超值服

開通VIP
python爬蟲下載網(wǎng)站所有文件

核心思路是使用正則表達(dá)式對網(wǎng)頁的html5中的路徑名和文件名進(jìn)行抓取,

然后對路徑繼續(xù)進(jìn)行同樣的抓取,用遞歸的方式進(jìn)行搜索。最后把網(wǎng)站上的內(nèi)容文件全部下載下來

import urllib

import sys
import BeautifulSoup
import re
import os

path = []

def extract(url):
    content = urllib.urlopen(url).read()
    #reg = r'(?:href|HREF)="?((?:http://)?.+?\.txt)'    
    reg = r'<a href="(.*)">.*'
    url_re = re.compile(reg)
    url_lst = re.findall(url_re, content)

    for lst in url_lst:
        ext = lst.split('.')[-1]
    
        if ext[-1] == '/':
           newUrl = url + lst
           extract(newUrl)
        else:
            path.append(url + lst)
       


print "downloading with urllib"
url = 'http://139.196.233.65/js/'
extract(url)

filePath = 'E:/6-學(xué)習(xí)文檔/91-JS/Download/js'
filePath = unicode(filePath, 'utf8')

for p in path:
    fileTitle = p.split('/js')[-1]
    file = filePath + fileTitle
    dir = os.path.dirname(file)
    isExists=os.path.exists(dir)

    if isExists == False:
        os.makedirs(dir)
    urllib.urlretrieve(p, file)






#for lst in url_lst:
#    file = filePath + lst
#    lst = url + '/' + lst
#    urllib.urlretrieve(lst, file)




本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點(diǎn)擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Python爬蟲爬取百度搜索結(jié)果
利用Python3爬蟲唯一圖庫網(wǎng)上的漂亮妹子圖ok
python 2.x和3.x的區(qū)別
Python 實(shí)現(xiàn)中國天氣小爬蟲
Python爬蟲日記一:爬取豆瓣電影中速度與激情8演員圖片
python爬蟲實(shí)踐之網(wǎng)頁抓取 | IT癮
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點(diǎn)擊這里聯(lián)系客服!

聯(lián)系客服