O
O
onlinejunior2020-05-31 12:18:17
go
onlinejunior, 2020-05-31 12:18:17

How to select tr and td correctly in goquery?

The site responds like this:

<tr >
   <td class="num">
     
   </td>
   <td class="co">
      
   </td>
   <td class="pla">
      
   </td>
   <td class="res">
   
   </td>
</tr>
<tr   class="odd"   >
   <td class="num">
   
   </td>
   <td class="co">
       
   </td>
   <td class="pla">
    
   </td>
   <td class="res">
       
   </td>
</tr>
<tr >
   <td class="num">
      
   </td>
    
   </td>
   <td class="pla">
      
   </td>
   <td class="res">
     
   </td>
</tr>


When I try to get value like:
query.Find("tr").Each(func(index int, trhtml *goquery.Selection) {

    fmt.Printf("%d:%s\n", index, trhtml.Text())
  })


Why am I getting an empty response?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
F
falconandy, 2020-05-31
@onlinejunior

It will work if you wrap it in a tag table.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question