-
-
Save jerome/8883363 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# -- coding: utf-8 | |
require "rubygems" | |
require "grill" | |
Grill.implant <<-GEM | |
source :rubygems | |
gem 'capybara', :require => ["capybara", "capybara/dsl"] | |
gem "capybara-webkit" | |
gem "headless" | |
GEM | |
module Agent | |
Capybara.default_driver = :webkit | |
def self.run(options={}, &block) | |
h = Headless.new(options) | |
h.start | |
agent = Class.new do | |
include Capybara::DSL | |
end.new | |
ObjectSpace.define_finalizer(agent) do | |
h.destroy | |
end | |
agent.instance_eval &block | |
end | |
end | |
images = [] | |
Agent.run do |agent| | |
login = "https://delicious.com/login" | |
visit login | |
within("#login-form") do | |
fill_in("username", :with => "[USER ID]") | |
fill_in("password", :with => "[PASSWORD]") | |
end | |
find('a.loginSubmit').click | |
while current_url == login | |
sleep 0.1 | |
end | |
puts current_url | |
find('#allCheck').click | |
find('a[a="private"]').click | |
find('a[a="click|confirm"]').click | |
while (find('p.loading') rescue nil) | |
sleep 0.1 | |
end | |
puts :done | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment