I have an HTML file (from Newegg) and their HTML is organized like below. All of the data in their specifications table is 'desc' while the titles of each section are in 'name.' Below are two examples of data from Newegg pages.
<tr>
<td class="name">Brand</td>
<td class="desc">Intel</td>
</tr>
<tr>
<td class="name">Series</td>
<td class="desc">Core i5</td>
</tr>
<tr>
<td class="name">Cores</td>
<td class="desc">4</td>
</tr>
<tr>
<td class="name">Socket</td>
<td class="desc">LGA 1156</td>
<tr>
<td class="name">Brand</td>
<td class="desc">AMD</td>
</tr>
<tr>
<td class="name">Series</td>
<td class="desc">Phenom II X4</td>
</tr>
<tr>
<td class="name">Cores</td>
<td class="desc">4</td>
</tr>
<tr>
<td class="name">Socket</td>
<td class="desc">Socket AM3</td>
</tr>
In the end I would like to have a class for a CPU (which is already set up) that consists of a Brand, Series, Cores, and Socket type to store each of the data. This is the only way I can think of to go about doing this:
if(parsedDocument.xpath(tr/td[@class="name"])=='Brand'):
CPU.brand = parsedDocument.xpath(tr/td[@class="name"]/nextsibling?).text
And doing this for the rest of the values. How would I accomplish the nextsibling and is there an easier way of doing this?
Thanks a bunch