jeudi 11 mai 2017

C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/common/service.rb:59:in `binary_path

I'm new to Ruby and I have very little practice. I'm having difficulty compiling the instabot that is demonstrated in the following video: Build an Instagram autofollow bot

The error message is:

C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/common/service.rb:59:in `binary_path':  Unable to find chromedriver. Please download the server from http://ift.tt/1hV5c2G and place it somewhere on your PATH. More info at http://ift.tt/1MNpI1r. (Selenium::WebDriver::Error::WebDriverError)
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/common/service.rb:49:in `initialize'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/chrome/bridge.rb:47:in `new'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/chrome/bridge.rb:47:in `initialize'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/common/driver.rb:61:in `new'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver/common/driver.rb:61:in `for'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/selenium-webdriver-3.4.0/lib/selenium/webdriver.rb:88:in `for'
        from C:/Ruby23-x64/lib/ruby/gems/2.3.0/gems/watir-6.2.1/lib/watir/browser.rb:46:in `initialize'
        from auto_follow.rb:16:in `new'
        from auto_follow.rb:16:in `<main>'

My code is like this:

require 'watir' # Crawler
require 'pry' # Ruby REPL
require 'rb-readline' # Ruby IRB
require 'awesome_print' # Console output
require_relative 'credentials' # Pulls in login credentials from credentials.rb

username = $username
password = $password
users = ["josephineskriver", "theweeknd", "kendalljenner", "karliekloss"]
follow_counter = 0
unfollow_counter = 0
MAX_UNFOLLOWS = 200
start_time = Time.now

# Open Browser, Navigate to Login page
browser = Watir::Browser.new :chrome, switches: ['--incognito']
browser.goto "http://ift.tt/1pHgwUl"

# Navigate to Username and Password fields, inject info
puts "Logging in..."
browser.text_field(:name => "username").set "#{username}"
browser.text_field(:name => "password").set "#{password}"

# Click Login Button
browser.button(:class => '_ah57t _84y62 _i46jh _rmr7s').click
sleep(2)
puts "We're in #hackerman"

# Continuous loop to run until you've unfollowed the max people for the day
loop do
  users.each { |val|
    # Navigate to user's page
    browser.goto "http://ift.tt/2r60sil"

    # If not following then follow
    if browser.button(:class => '_ah57t _84y62 _frcv2 _rmr7s').exists?
      ap "Following #{val}"
      browser.button(:class => '_ah57t _84y62 _frcv2 _rmr7s').click
      follow_counter += 1
    elsif browser.button(:class => '_ah57t _6y2ah _frcv2 _rmr7s').exists?
      ap "Unfollowing #{val}"
      browser.button(:class => '_ah57t _6y2ah _frcv2 _rmr7s').click
      unfollow_counter += 1
    end
    sleep(1.0/2.0) # Sleep half a second to not get tripped up when un/following many users at once
  }
  puts "--------- #{Time.now} ----------"
  break if unfollow_counter >= MAX_UNFOLLOWS
  sleep(30) # Sleep 1 hour (3600 seconds)
end

ap "Followed #{follow_counter} users and unfollowed #{unfollow_counter} in #{((Time.now - start_time)/60).round(2)} minutes"

# Leave this in to use the REPL at end of program
# Otherwise, take it out and program will just end
Pry.start(binding)

# Top 100 users on Instagram
# users = ['instagram', 'selenagomez', 'arianagrande', 'taylorswift', 'beyonce', 'kimkardashian', 'cristiano', 'kyliejenner', 'justinbieber', 'kendalljenner', 'nickiminaj', 'natgeo', 'neymarjr', 'nike', 'leomessi','khloekardashian', 'mileycyrus', 'katyperry', 'jlo', 'ddlovato', 'kourtneykardash', 'victoriasecret', 'badgalriri', 'fcbarcelona', 'realmadrid', 'theellenshow', 'justintimberlake', 'zendaya' 'caradelevingne', '9gag', 'chrisbrownofficial', 'vindiesel', 'champagnepapi', 'davidbeckham', 'shakira', 'gigihadid', 'emmawatson', 'jamesrodiguez10', 'kingjames', 'garethbale11', 'nikefootball', 'adele', 'zacefron', 'vanessahudgens', 'ladygaga', 'maluma', 'nba', 'nasa', 'rondaldinho', 'luissuarez9', 'zayn', 'shawnmendes', 'adidasfootball', 'brumarquezine', 'hm', 'harrystyles','chanelofficial', 'ayutingting92', 'letthelordbewithyou', 'niallhoran', 'anitta', 'hudabeauty', 'camerondallas', 'adidasoriginals', 'marinaruybarbosa', 'lucyhale', 'karimbenzema', 'princessyahrini', 'zara', 'nickyjampr', 'onedirection', 'andresiniesta8', 'raffinagita1717', 'krisjenner', 'manchesterunited', 'natgeotravel', 'marcelottwelve', 'deepikapadukone', 'snoopdogg', 'davidluiz_4', 'kalbiminrozeti', 'priyankachopra', 'ashleybenson', 'shaym', 'lelepons', 'prillylatuconsina96','louisvuitton','britneyspears', 'sr4official', 'jbalvin', 'laudyacynthiabella', 'ciara', 'stephencurry30', 'instagrambrasil']

Aucun commentaire:

Enregistrer un commentaire