I solve the training problem and try to parse the course data with the courser . On the site, almost every tag has a data-reactid attribute. For example:

<td class="td-data" data-reactid="155">10 weeks of study</td> 

And this code returns None:

 import requests from bs4 import BeautifulSoup response = requests.get('https://www.coursera.org/learn/stalinism') soup = BeautifulSoup(response.text, 'html.parser') print(soup.find('td', attrs={'class': 'td-data', 'data-reactid': '155'})) 

As suggested to me here, this happens because when loading this argument changes the value. Explain what the data-reactid is? Initially data-reactid = 155, but when loaded into request.text, data-reactid = 163. Why is this happening?

Online: enter image description here

In response.text: enter image description here

  • create a minimal but complete example, a code that shows the problem. What do you think is wrong? What did you expect to receive? How is this different from what you expected? The minimum reproducible example is jfs
  • @jfs added a minimal example. - Serg4356
  • in other words you want to ask: how to get the text from the element? (get_text ()) - jfs
  • In fact, I managed to get the text, I wanted to know why this attribute does not work, this is a unique attribute - Serg4356
  • one
    to demonstrate that the find call works. Debugging is a step by step process. This will help localize the problem. To understand what part of the code is an error¶ you can of course do nothing (I leave comments to you longer than the sample code the worker took before the very first comment.) Follow the instructions for the minimum reproducible example - jfs

0