Skip to content

Instantly share code, notes, and snippets.

@chrisle
Created December 4, 2012 18:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save chrisle/4206925 to your computer and use it in GitHub Desktop.
Save chrisle/4206925 to your computer and use it in GitHub Desktop.
newspaper to seomoz
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