4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/fb_error_machine/graph_error_scraper.rb', line 4
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
|