Created
December 4, 2012 18:01
-
-
Save chrisle/4206925 to your computer and use it in GitHub Desktop.
newspaper to seomoz
This file contains 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 'mechanize' | |
require 'linkscape' | |
agent = Mechanize.new | |
agent.user_agent_alias = 'Mac Safari' | |
# Put your state here | |
state = "PA" | |
page = agent.get "http://newsmap.mhlakhani.com/data/US-#{state}" | |
newspapers = JSON.parse(page.body) | |
linkscape_client = Linkscape::Client.new( | |
:accessID => "YOUR ACCESS ID HERE", | |
:secret => "YOUR SECRET HERE") | |
newspapers.each do |newspaper| | |
url = newspaper[5] | |
response = linkscape_client.urlMetrics(url, :cols => :all) | |
# put Whatever metric you want here.... | |
da = response.data[:domain_authority] | |
puts "#{url}, DA=#{da}" | |
end | |
# example output: | |
# http://www.bignewsnetwork.com/index.php/cat/3e0f27c4f0bf8c91/, DA=71.64233486013697 | |
# http://www.einnews.com/pennsylvania/, DA=81.18480018803938 | |
# .... and so on... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment