Sort list of nodes by attribute

1

I'm parseando this web link . For this I need to know the header, in which the full date comes, plus the nodes that contain each game. I need to do it sequentially, because in the same table there is more than one header with different dates. When the row that says "Results" is reached, exit.

For this, what I do is create a list that contains all the nodes of the 3 types

<tr class="Leaguestitle">   Los nodos de título
<tr id="tr1....">           Los nodos con cada partido
<tr align="center">         El nodo Results

I use the following xpath that gives me the list of nodes:

allrows=table.find_elements_by_xpath(
        './/tr[@class="Leaguestitle"] | .//tr[contains(@id,"tr1")] | .//tr[@align="center"]')

What I want is to make a for loop, and classify the nodes as follows:

  • If it is class="Leaguestitle", save the date in a variable
  • If id="tr1 ...", generate a list with all those nodes and the date in the variable
  • If it's align="center" end

The problem is that each node of the loop instead of being

With the node tr and its attributes, what I get is this

That not having tr does not allow me to filter by the attributes.

How do I get the node with everything?

    
asked by puppet 31.12.2017 в 12:30
source

1 answer

0

Ok I discovered the problem. To look at the node I was using row.get_attribute("innerHTML") that the inside gave me, if I use row.get_attribute("outerHTML") I get the complete node, so I should be able to do what I want using row.get_attribute()

    
answered by 31.12.2017 в 13:18