2017-08-07 43 views
0

這是從那裏我試圖提取子表從表中的iMacros

我試圖提取數據 我只是想從一個表中提取子表下建築詳細信息類別的webpage

TAG POS=1 TYPE=H2 ATTR=TXT:Building<SP>Details 
TAG POS=R1 TYPE=TABLE ATTR=TXT:* EXTRACT=HTM 
SET txt1 {{!EXTRACT}} 
SET count_txt EVAL(("var n=\"{{txt1}}\";var a=n.match(/<table class=\"table table-bordered table-responsive table-striped\">/g) || []).length;a;") 
PROMPT {{count_txt}} 

在這段代碼中,我第一次計數文本'<table class=\"table table-bordered table-responsive table-striped\"'的發生,並在此基礎上努力潑了HTM,然後提取數據,但是這是給我的錯誤

MacroSyntaxError: wrong format of SET command, line 4 (Error code: -910) 

我試圖讓這樣的事情

 Sr.No. Project_Name  Name     Number of Basement's Number of Plinth Number of Podium's Number_of_Slab_of_Super_Structure Number_of_Stilts Number_of Open_Parking Number_of_Closed_Parking Sr.No. Apartment_Type Carpet_Area_(in Sqmts) Number_of_Apartment Number_of_Booked_Apartment 
      1  SERENE CITY SERENE CITY A-01/A-02  0      1     0        2        0    0      0      1  VILLA 2BHK 234.3        2       0 
      2  SERENE CITY SERENE CITY A-03/A-04  0     1     0        2        0    0      0      1  VILLA 2BHK     234.3     2       0 

截至本記錄有... 任何幫助將非常感激。

感謝

回答

0

使用我的宏這將是非常乏味的事情,因爲只有一個表,有一個重複的圖案,我已經寫了一些CSS中,你可以得到只有你通過副本所需的線糊。

說明:

你需要該行是該系列1,5,9,......所以我用的是第n個孩子選擇器(檢查出來here),這將只顯示想要的行。然後,表格內的所有tr被設置爲不顯示,這將隱藏它。

tbody > tr:nth-child(4n+2) { 
    display: table !important; 
} 
tbody > tr { 
    display: none !important; 
} 

輸出: enter image description here

+0

@deepesh這個答案對您有幫助嗎? –

0

這應該工作(「count_txt」必須被預先定義,「m」是與相應的類表中的號碼,「i」是表中內的行數這種情況),但是您需要手動添加列標題:

for(m=1;m<=count_txt;m++){ 
    var macro; 
    var rows=10; 
    var tag = "TAG XPATH=\".//body/descendant::table[@class="table table-bordered table-striped"][{{m}}]/tbody/tr[{{i}}]/td[3]\" EXTRACT=TXT" 
    macro = "CODE:"; 
    macro += tag; 
    iimPlay("CODE:ADD !EXTRACT {{!m}}");//row# 
    for(i=1;i<=rows;i++){ 
    iimSet("i",i); 
    iimPlay(macro);//extract data 
    } 
    iimPlay("CODE:SAVEAS TYPE=EXTRACT FOLDER=* FILE=MyTable.csv");//save 
    }