Created
February 7, 2024 04:32
-
-
Save fsndzomga/af359abdfe66d33ccdbc4dab008556d3 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'nokogiri' | |
require 'watir' | |
require 'webdrivers' | |
def count_happy_scribe_ruby(url) | |
browser = Watir::Browser.new :chrome, headless: true | |
browser.goto(url) | |
browser.execute_script("window.scrollTo(0, document.body.scrollHeight)") | |
sleep(10) # Wait a bit more for content to load | |
html = browser.html | |
browser.quit | |
count = html.scan("Happy Scribe").count | |
puts "Happy Scribe appears #{count} times." | |
end | |
count_happy_scribe_ruby("https://www.happyscribe.com") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment