Sha256: 83b125379ee89923e3ec6d792f0d6b106ce1063796035f77959450701ad04efc

Contents?: true

Size: 963 Bytes

Versions: 1

Compression:

Stored size: 963 Bytes

Contents

module FbErrorMachine
  class GraphErrorScraper

    def self.scrape_graph_api_errors(version="2.7")
      browser = Watir::Browser.new :phantomjs
      browser.goto("https://developers.facebook.com/docs/graph-api/using-graph-api/v#{version}")

      error_table = browser.table(xpath: '//*[@id="u_0_0"]/div/span/div/div[8]/div/div[1]/table')
      error_rows = error_table.rows.to_a
      error_rows.shift

      auth_table = browser.table(xpath: '//*[@id="u_0_0"]/div/span/div/div[8]/div/div[2]/table')
      auth_rows = auth_table.rows.to_a
      auth_rows.shift

      rows = error_rows + auth_rows
      errors = []

      rows.each do |row|
        errors << {
          error_code: ErrorWriter.find_error_code(row),
          description: ErrorWriter.find_description(row),
          instructions: ErrorWriter.find_instructions(row),
        }
      end

      browser.close
      ErrorWriter.write_errors(type: 'graph', errors: errors)
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
fb_error_machine-0.1.1 lib/fb_error_machine/graph_error_scraper.rb