2013-11-01 194 views
0

我想在Excel中使用VBA自動化頁面刮擦程序,但難以從網頁獲得結果,因爲我想要的字段沒有ID,我已經複製了下面的源代碼我認爲它包含在一張表中?你如何使用td Class和Class來獲取數據?從網站獲取數據返回excel

<table> 
       <tbody> 
        <tr> 
         <td class="vehicledetailstableleft"><span class="bodytextbold">Date of Liability</span></td> 
         <td class="vehicledetailstableright"><span class="bodytext">01 07 2014</span></td> 
        </tr> 
          <tr> 
           <td class="vehicledetailstableleft"><span class="bodytextbold">Date of First Registration</span></td> 
           <td class="vehicledetailstableright"><span class="bodytext">02 07 2013</span></td> 
          </tr> 
        <tr> 
         <td class="vehicledetailstableleft"><span class="bodytextbold">Year of Manufacture</span></td> 
         <td class="vehicledetailstableright"><span class="bodytext">2013</span></td> 
        </tr> 
        <tr> 
         <td class="vehicledetailstableleft"><span class="bodytextbold">Cylinder Capacity (cc)</span></td> 
         <td class="vehicledetailstableright"><span class="bodytext">2993cc</span></td> 
        </tr> 
        <tr> 
         <td class="vehicledetailstableleft"><span class="bodytextbold">CO&#8322; Emissions</span></td> 
         <td class="vehicledetailstableright"><span class="bodytext">129 g/km</span></td> 
        </tr> 
        <tr> 
         <td class="vehicledetailstableleft"><span class="bodytextbold">Fuel Type</span></td> 
         <td class="vehicledetailstableright"><span id="fueltype" class="bodytext">HEAVY OIL</span></td> 
        </tr> 
        <tr> 
         <td class="vehicledetailstableleft"><span class="bodytextbold">Export Marker</span></td> 
         <td class="vehicledetailstableright"><span id="exportmarker" class="bodytext">N</span></td> 
        </tr> 
        <tr> 
         <td class="vehicledetailstableleft"><span class="bodytextbold">Vehicle Status</span></td> 
         <td class="vehicledetailstableright"><span id="vehiclelicencestatus" class="bodytext">Licence Not Due</span></td> 
        </tr> 
        <tr> 
         <td class="vehicledetailstableleft"><span class="bodytextbold">Vehicle Colour</span></td> 
         <td class="vehicledetailstableright"><span id="colour" class="bodytext">BLUE</span></td> 
        </tr> 
        <tr> 
         <td class="vehicledetailstableleft"><span class="bodytextbold">Vehicle Type Approval</span></td> 
         <td class="vehicledetailstableright"><span class="bodytext">M1</span></td> 
        </tr> 
         <tr> 
          <td class="vehicledetailstableleft"><span class="bodytextbold">Date of Last V5C Issued</span> 
          </td> 
          <td class="vehicledetailstableright"><span class="bodytext">No Result Found</span> 
          </td> 
         </tr> 
+0

爲什麼不直接使用內置的Excel Web Query? – user2140261

+0

您可以使用'objIE.document.getElementsByTagname(「tr」)'獲取所有錶行,然後在每個tr上執行相同的操作以獲取td元素。如果您需要獲得該類,請查看className屬性。 –

+0

@ user2140261 This [link](http://stackoverflow.com/questions/15844342/pulling-upside-downside-capture-ratio-from-morningstar-com/15853293#15853293)可能會有所幫助。 – Santosh

回答