how beautifulsoup colindex numbers?
i problem week ago. given i cruise fortitude cold i am pity here while i am sharp an answer doubt i posted earlier. i need know family position buttress headings list i know review buttress streamer adult information rows below. i found tables following quarrel initial quarrel table
<!-- list extent quarrel -->
<tr style="font-size: 1pt" valign="bottom">
<td width="60%"> </td> <!-- colindex=01 type=maindata -->
<td width="1%"> </td> <!-- colindex=02 type=gutter -->
<td width="1%" align="right"> </td> <!-- colindex=02 type=lead -->
<td width="9%" align="right"> </td> <!-- colindex=02 type=body -->
<td width="1%" align="left"> </td> <!-- colindex=02 type=hang1 -->
<td width="3%"> </td> <!-- colindex=03 type=gutter -->
<td width="1%" align="right"> </td> <!-- colindex=03 type=lead -->
<td width="4%" align="right"> </td> <!-- colindex=03 type=body -->
<td width="1%" align="left"> </td> <!-- colindex=03 type=hang1 -->
<td width="3%"> </td> <!-- colindex=04 type=gutter -->
<td width="1%" align="right"> </td> <!-- colindex=04 type=lead -->
<td width="4%" align="right"> </td> <!-- colindex=04 type=body -->
<td width="1%" align="left"> </td> <!-- colindex=04 type=hang1 -->
<td width="3%"> </td> <!-- colindex=05 type=gutter -->
<td width="1%" align="right"> </td> <!-- colindex=05 type=lead -->
<td width="5%" align="right"> </td> <!-- colindex=05 type=body -->
<td width="1%" align="left"> </td> <!-- colindex=05 type=hang1 -->
</tr>
i guess wow, easy since information buttress next type=body. counting down i knew information rows i need values columns [3, 7, 11, 15]. i set out accomplish controlling code:
indexcomment = souptogetcolindex.findall(text=re.compile("type=body"))
indexrow=indexcomment[0].findparent()
indexcells=indexrow.findall(text=re.compile("type=body"))
for any range(len(indexcells)):
collist.append(tdlist.index(indexcells[each].previoussibling.previoussibling))
what i got behind collist=[0, 3, 7, 7, 15]
it turns out i cruise since cells 7th 11th position looked accurately comparison same index position returned. i perplexing figure out understanding this, clearly i feeling different. i feeling opposite initial controlling readlines review any line record change vacant spaces futile integer.
for any togetcolindex:
newlt.append(each.replace(r" ",str(random.randint(1,14567))))
a associate separate out i devaluate over controlling instead
for any togetcolindex:
newlt.append(each.replace(r" ",str(togetcolindex.index(each))))
nonetheless, any approaches gets me list colindex plcae headers any buttress information rows. note reinstate duty blank vacant space given i speculation html causing disappear tangible formula uses r"&.n.b.s.p;" but periods
Comments
Post a Comment