require 'selenium-webdriver'
driver = Selenium::WebDriver.for :chrome
driver.navigate.to 'https://dreams.dokkyo.ac.jp/campusweb/campusportal.do'
id = driver.find_element(:xpath,'//[@id="userNameInput"]')
pass = driver.find_element(:xpath,'//[@id="passwordInput"]')
id.send_keys("")
pass.send_keys("")
driver.find_element(:xpath,'//*[@id="LoginFormSimple"]/tbody/tr[3]/td/button[1]').click
wait = Selenium::WebDriver::Wait.new(timeout: 3)
driver.navigate.to 'https://dreams.dokkyo.ac.jp/campusweb/campusportal.do?page=main&tabId=sb'
wait = Selenium::WebDriver::Wait.new(timeout: 3)
sinchaku = driver.find_elements(:xpath,'/html/body/table/tbody/tr[1]')
sinchaku.each do |i|
puts i.text
end
seleniumを使ったこのスクレイピングの書き方だと以下のようなエラーが出ます。これは何がいけないのでしょうか?
raceback (most recent call last):
9: from scraping.rb:7:in <main>' 8: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver.rb:88:in
for'
7: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/driver.rb:46:in for' 6: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/driver.rb:46:in
new'
5: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/chrome/driver.rb:40:in initialize' 4: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/driver.rb:299:in
service_url'
3: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/service.rb:41:in chrome' 2: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/service.rb:41:in
new'
1: from /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/service.rb:94:in initialize' /home/ec2-user/.rvm/gems/ruby-2.6.3/gems/selenium-webdriver-3.142.7/lib/selenium/webdriver/common/service.rb:136:in
binary_path': Unable to find chromedriver. Please download the server from (Selenium::WebDriver::Error::WebDriverError)
https://chromedriver.storage.googleapis.com/index.html and place it somewhere on your PATH.
More info at https://github.com/SeleniumHQ/selenium/wiki/ChromeDriver.
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。