lib/selenium_scraper.rb in my-congress-0.2.2 vs lib/selenium_scraper.rb in my-congress-0.2.3
- old
+ new
@@ -1,8 +1,8 @@
class SeleniumScraper
- def initialize(site, state)
+ def initialize(site, address)
# Launch Chrome behind the scenes & scrape website
options = Selenium::WebDriver::Chrome::Options.new(args: ['headless'])
driver = Selenium::WebDriver.for(:chrome, options: options)
driver.get(site)
@@ -11,13 +11,13 @@
info = driver.find_elements(css: 'div.row.oa-elected-official-group-list-item')
#Error for not locating address / invalid address
if info[3] == nil
puts " "
- puts "Could not locate address. Press 'Enter' to return to Main Menu.".colorize(:blue)
- nothing = gets.chomp
- MCongress.new.call
+ prompt = TTY::Prompt.new
+ prompt.keypress("Could not find address. Press any key to return to Main Menu.".colorize(:red))
+ MyCongress.new.call
end
# Once Selenium passes the refresh, Nokogiri is easier
# to target the actual elements we need
elements = Nokogiri::HTML(open(driver.current_url))
@@ -28,9 +28,9 @@
rep = info[5].text.split("\n")
driver.quit
# Sent to FindRepresentatives method to organize info for display
- FindRepresentatives.new(sen1, sen2, rep, elements, state)
+ FindRepresentatives.new(sen1, sen2, rep, elements, address)
end
end
\ No newline at end of file