如何使用GET请求从http://moz.com获取域名管理员?

时间:2014-10-25 13:17:07

标签: html ruby rest seo

我想从“moz.com”获得域名权限值(没有找到其他来源)。 有时页面无法正确加载,并且来自moz.com的响应没有我解析的正确dom元素。可能页面使用javascript来显示值。它也有限制,不能分析超过3次/天(我需要每天最多访问一次)

require 'rest-client'
require 'nokogiri'

link_url = "http://google.com"
api_url  = "http://moz.com/researchtools/ose/links?site="
response = RestClient.get(api_url + link_url.split("?").first)
value    = Nokogiri::HTML(response).css('.url-metrics-authority span.large').first.text.strip #previously there was Nokogiri::HTML(response).css('.metrics-authority').first.text.strip
pp value

从运行良好的控制台,但是当我使用ruby脚本运行它时,它失败了。 我可以以某种方式等待js执行,还是有任何其他来源获得域名权限?

2 个答案:

答案 0 :(得分:1)

您可以通过使用Moz提供的免费URL Metrics API来获得任何网站/ URL的域授权。您将需要AccessId和密钥才能使用Mozscape API。我建议您围绕Moz API构建包装器API to get Moz Domain Authority,以便可以使用Javascript中的包装器API。

答案 1 :(得分:0)

我是Russ Jones,并为Moz咨询。我还帮助设计了最新版本的域授权。

collecting Domain Authority is here的适当文档

获取API Key is free并允许每月进行2500次查找,但每10秒不超过1次。付费访问的起步价为$ 250 /月,包括每月12万行,而且限制更少。