Skip to content

Instantly share code, notes, and snippets.

@artemave
Last active August 29, 2015 13:56
Show Gist options
  • Save artemave/8794022 to your computer and use it in GitHub Desktop.
Save artemave/8794022 to your computer and use it in GitHub Desktop.
source 'https://rubygems.org'
gem 'capybara'
gem 'poltergeist'
require 'capybara/dsl'
require 'capybara/poltergeist'
Capybara.register_driver :poltergeist do |app|
Capybara::Poltergeist::Driver.new(app, timeout: 120)
end
Capybara.default_driver = :poltergeist
def geist url
if rand(3) == 0
url = url
puts Time.now, url
Capybara.visit url
end
sleep rand(5) + 5
rescue Capybara::Poltergeist::JavascriptError => e
puts e.message
end
keywords = %w[stuff books bus joy toy dress shoes apple]
Capybara.visit "https://artem-shopa-staging.herokuapp.com/accounts/sign_in"
Capybara.fill_in "Email", with: 'artemave@gmail.com'
Capybara.fill_in "Password", with: 'password'
Capybara.click_button 'Submit'
while true do
# geist "https://artem-shopa-staging.herokuapp.com/products?keywords=#{keywords.sample}"
# geist "https://artem-shopa-staging.herokuapp.com/myshopa/interests/remove"
# geist "https://artem-shopa-staging.herokuapp.com/myshopa/interests"
# geist "https://artem-shopa-staging.herokuapp.com/myshopa/click_score"
geist "https://artem-shopa-staging.herokuapp.com/products/L37537L10511011-a-game-of-thrones"
geist "https://artem-shopa-staging.herokuapp.com/products/L38199L855967502-musashi"
geist "https://artem-shopa-staging.herokuapp.com/products/L38199L851628006-forbidden-planet-entertainment-store-exclusive-bluray-steelbook"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment