2 years ago

#13387

test-img

Annu

Count of a specific word from the entire website in Python

I need to find the matches of a WORD from the entire website, for example:

Find all the words "tutorial" in the web https://www.w3schools.com/

I tried the following Python code but it returns me the count of home pages and its dropdown tabs "tutorial" counts only, I want to get the count of "tutorial" from the entire website, i.e. if taken to another page of the same website it should count the word tutorial from there also.

import requests
from bs4 import BeautifulSoup
import re
page = requests.get("https://www.w3schools.com/")
soup = BeautifulSoup(page.text, 'html.parser')
solo_body = soup.body
body = solo_body.text.lower()
train_count = (body.count("tutorial"))
print(train_count)

python

beautifulsoup

web-crawler

logic

bs4dash

0 Answers

Your Answer

Accepted video resources