Issue
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'?
Solution
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.
Answered By - Rodrigo Laguna
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.