Skip to content

Instantly share code, notes, and snippets.

@fsndzomga
Created February 7, 2024 04:32
Show Gist options
  • Save fsndzomga/af359abdfe66d33ccdbc4dab008556d3 to your computer and use it in GitHub Desktop.
Save fsndzomga/af359abdfe66d33ccdbc4dab008556d3 to your computer and use it in GitHub Desktop.
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