I am trying to count how many times an string "Airport" appears on an website. I tried to use Request Module , BS4 etc. and tried to scrap data from there, but the REST response returns a very concise xml which actually does not contain the text in it. Find_Element_By_Link_Text method also does not work here as the string "Airport" is part of the texts shown on the page. Is there any method that I can use to count the number of occurrences of the text "Airport" on the page?
Asked
Active
Viewed 1,426 times
2 Answers
2
You can use browser.page_source, convert it to a string and use regular expression findall.

nicholas.reichel
- 2,260
- 7
- 20
- 28
-1
why don't you use some javascript?
get all the html code/text
var wholeText = document.documentElement.innerHTML;
then split by "Airport"
var repeat = wholeText.split("Airport");
finally count the elements in your repeat array
total = repeat.length -1
this should give you all the airports in the whole code (including backend)
another easy approach is just use your Ctrl + F and find the occurrences manually

Developer Guy
- 2,318
- 6
- 19
- 37

Mike
- 789
- 8
- 15