0

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)
Annu
  • 23
  • 4
  • 3
    I dont think this is possible. A page is loaded in the browser only when you go to it. So even if a website has multiple pages, it is not loaded until you go to it. And even then you only get the count of occurences in the code not the webpage. i.e a word maybe in code but not displayed. You are pulling html content which has code. You can only get info based on that. – leoOrion Jan 05 '22 at 08:40
  • If possible can you help me with that? @leoOrion – Annu Jan 05 '22 at 09:41
  • @Sufiyan-Ghori can you help? – Annu Jan 05 '22 at 09:43
  • Its not possible though.... – leoOrion Jan 06 '22 at 03:11

0 Answers0