2017-02-22 44 views
1

我有問題在我的代碼,它只提取數據從變量id並不提取標題。但是,如果我刪除id的提取,標題是保存,我想這可能是我提取HTM的問題。 有人可以解釋我做錯了什麼嗎?當提取HTM它不保存數據到文件

var i = 1; 

while(iimPlayCode('SET !TIMEOUT_STEP 1\nTAG POS='+i+' TYPE=A ATTR=CLASS:"pl-video-title-link*" CONTENT=EVENT:MOUSEOVER')>0) { 

    iimPlayCode('TAG POS='+i+' TYPE=A ATTR=CLASS:"pl-video-title-link*" EXTRACT=TXT\n') 
    var title = iimGetLastExtract(); 
    var title = title.replace(/\s+/g, ''); 
    iimSet('title',title); 


    iimPlayCode('TAG POS='+i+' TYPE=TR ATTR=data-video-id:"*" EXTRACT=HTM\n') 
    var id = iimGetLastExtract(); 
    var id = id.match(/data-video-id="(.+?)"/)[1]; 
    iimSet('id',id); 

    iimPlayCode('SET !EXTRACT {{title}}\nSET !EXTRACT {{id}}\nSAVEAS TYPE=EXTRACT FOLDER=* FILE=Output_for_Youtube_Playlist.csv\n'); 
    i++; 
} 

回答

1

好吧,我跟我看着辦吧,我忘了把空單引號之間的正則表達式,我認爲這是問題,我重拍劇本的結構

while(iimPlayCode('SET !TIMEOUT_STEP 1\nTAG POS='+i+' TYPE=A ATTR=CLASS:"pl-video-title-link*" CONTENT=EVENT:MOUSEOVER')>0) { 

    iimPlay('Code:' 
     + 'TAG POS='+i+' TYPE=A ATTR=CLASS:"pl-video-title-link*" EXTRACT=TXT\n' 
     + 'TAG POS='+i+' TYPE=TR ATTR=data-video-id:"*" EXTRACT=HTM\n' 
    ) 

    var title = iimGetExtract(1); 
    title = title.replace(/\s+/g, ' '); 

    var id = iimGetExtract(2); 
    var id = id.match(/data-video-id="(.+?)"/)[1]; 

    saveRes = 'CODE:'; 
    saveRes += 'ADD !EXTRACT "'+title+'"' + '\n'; 
    saveRes += 'ADD !EXTRACT "'+id+'"' + '\n'; 
    saveRes += 'SAVEAS TYPE=EXTRACT FOLDER=* FILE=Output_for_Youtube_Playlist.csv\n'; 
    iimPlay(saveRes); 
    i++; 
} 
相關問題