Last active
August 29, 2015 14:08
-
-
Save nhoag/30e47e6a04c254f84410 to your computer and use it in GitHub Desktop.
Scrape Acquia's list of incompatible modules
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
require 'rubygems' | |
require 'mechanize' | |
require 'logger' | |
require 'nokogiri' | |
# Create a new mechanize object | |
mech = Mechanize.new | |
# Uncomment for verbose output | |
# mech.log = Logger.new $stderr | |
# mech.agent.http.debug_output = $stderr | |
# Load the Accounts site | |
page = mech.get('https://accounts.acquia.com/') | |
form = page.forms[0] | |
username_field = form.field_with(:id => 'edit-name') | |
username_field.value = 'your-email' # <- Add your email here | |
password_field = form.field_with(:id => 'edit-pass') | |
password_field.value = 'your-password' # <- Add your password here | |
form.submit form.buttons.first | |
incompatible = mech.get('https://docs.acquia.com/articles/module-incompatibilities-acquia-cloud'); | |
doc = Nokogiri::HTML(incompatible.body, "UTF-8") | |
doc.xpath('//tr').each do |item| | |
if !item.xpath('./td/a')[0].nil? | |
item.xpath('./td/a')[0].each do |x| | |
puts x[1].split('/')[-1] | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment