AnsweredAssumed Answered

Beautifulsoup count occurences of string

Question asked by jpilbeam Champion on Aug 19, 2020
Latest reply on Aug 20, 2020 by j0shNZ

I think this gets me the length of the text count for "COVID-19" because it prints 8.

import requests
from bs4 import BeautifulSoup
import re

url = r''

#request webpage
soup = BeautifulSoup(requests.get(url.content, "lxml")
#find occurences of string

>>> 8


When I do a CTRL+F for "COVID-19" on the webpage I get a count of 5 occurrences. When I do a CTRL+F for "COVID-19" in the Developer tools I get 15.


I'm trying to get the count for the total occurrences of the string "COVID-19". How can I set up the code to do that?