Problem with beautifulsoup of python

0

Good, I'm scraping on a website and I'm having a problem with beautifulsoup when it comes to listing the results, the page I'm dealing with has a structure like this:

<tr class="order-by-pos" data-pos="1">
<td class="normal-td td-center td-pos">
                                        1st                                            
      <div class="race-pos-no race-pos-no-2">2</div>
 </td>
</tr>




<tr class="order-by-pos" data-pos="2">
   <td class="normal-td td-center td-pos">
                                            2nd                                           
      <div class="race-pos-no race-pos-no-1">1</div>
   </td>
</tr>

and my code in python is:

registros = html.find_all(class_="order-by-pos")

for entrada in registros:

    saludos = entrada.find(class_="normal-td td-runner").get_text()
    trainer = entrada.find(class_="normal-td font-12 td-trainer").get_text()

    print (saludos,trainer)

I know that there are classes that do not appear in the above code, but I have avoided them so as not to hit so much, the problem in question is that you are not listing the top one first and starting with the one below, because it takes as a reference the class "race-post-no race-post-no1", and so on.

How could I make it start listing for the first one that would be "order-by-pos"?

    
asked by Manu 21.11.2017 в 15:13
source

0 answers