1
counter=0
for col in soup.find(class_='m-nktq8b'):
    if counter==0:
        counter+=1
        continue
    else:
        print(col)
        print(col['class'])

Above is my input, and below is my output:

<p class="m-1nj5h5j">Severe</p>

['m-1nj5h5j']

How could I further scrape the word between > and <, which is 'Severe'?

petergorrr
  • 29
  • 3

1 Answers1

0

You can extract this using regex:

import re

text = '<p class="m-1nj5h5j">Severe</p>'

print(re.search(r'<p .+?>(.+)</p>', text).group(1))

Output is:

Severe

However, it looks more like a work-around than a solution. A better solution is to extract this using just beautifulsoup's find:

counter = 0
for col in soup.find(class_="m-nktq8b"):
    if counter == 0:
        counter += 1
        continue
    else:
        # here is the line:
        print(col.find("p"))

Checkout this question for more information.

Rodrigo Laguna
  • 1,796
  • 1
  • 26
  • 46