lib/pintrest_api/core.rb
# Create a new PhantomJS session in Capybara
Create a new PhantomJS session in Capybara
Create a new PhantomJS session in Capybara
def new_session
        Capybara.register_driver :poltergeist do |app|
          Capybara::Poltergeist::Driver.new(app, timeout: 60, js_errors: false)
        end
        Capybara.default_selector = :css
        @session = Capybara::Session.new(:poltergeist)
        @session.driver.headers = { 'User-Agent' =>
          "Mozilla/5.0 (Macintosh; Intel Mac OS X)" }
        @session
      end
def new_session Capybara . register_driver :poltergeist do | app | Capybara :: Poltergeist :: Driver . new ( app , timeout : 60 , js_errors : false ) end Capybara . default_selector = :css @session = Capybara :: Session . new ( :poltergeist ) @session . driver . headers = { 'User-Agent' => "Mozilla/5.0 (Macintosh; Intel Mac OS X)" } @session end
Create a new PhantomJS session in Capybara
Create a new PhantomJS session in Capybara
# Register PhantomJS (aka poltergeist) as the driver to use # Use CSS as the default selector for the find method # Start up a new thread # Report using a particular user agent # Return the driver's session