Home > Software design >  how do I scrape text from same and same class
how do I scrape text from same and same class

Time:12-07

[my python code] ](https://i.stack.imgur.com/TfGSS.png)

I am not able to scrape 'points' . Number of matches have same tag and class ,so I am getting number of matches instead of point. I am new to this ,can anyone please help me. thanks

CodePudding user response:

Have you tried also applying the find_all function to the parts in the for-loop? Also, you can split at the end, to get the entries as single strings in a list.

CodePudding user response:

The match and points values have the same class name, so you need to specify the order in the DOM the element resides. The nth-child(1) function specifies which DOM element to target that is a <td> with the class table-body__cell u-center-text.

match = i.select_one('td', class_='table-body__cell u-center-text:nth-child(1)').text
points = i.select_one('td', class_='table-body__cell u-center-text:nth-child(2)').text

CodePudding user response:

Then try to use XPATH, since XPATH is always unique you won't get this type of error

  • Related