How find and count matches for a word - Python - Scrapping

1199 views python

I need found the matches of a WORD, for example:

Found all words "Learn" in the web (Result: 4 words) (you can see it press CTRL + F and search)

I have my Python code, but my count match is 3! If I look for another word, the result is one less or one more

import requests
from bs4 import BeautifulSoup
import re

page = requests.get("")
soup = BeautifulSoup(page.text, 'html.parser')
solo_body = soup.body
limpiar_body = solo_body.text
contar_coincidencias = (limpiar_body.count("learn"))

Actually use Python3, "find_all" not working for me.

answered question

1 Answer


you need to count both upper and lower case. replace limpiar_body = solo_body.text with limpiar_body = solo_body.text.lower()

posted this

Have an answer?


Please login first before posting an answer.