Skip to content

Instantly share code, notes, and snippets.

@ErvalhouS
Created April 9, 2018 14:09
Show Gist options
  • Save ErvalhouS/0fefde39f0fa4ade981a863392b85513 to your computer and use it in GitHub Desktop.
Save ErvalhouS/0fefde39f0fa4ade981a863392b85513 to your computer and use it in GitHub Desktop.
A rake task to ping main search providers with updated sitemap.xml
desc "rake 'latest:sitemap' Pings search engines with current channels sitemap addresses"
task sitemap: :environment do
def http_get(domain,path,params)
return Net::HTTP.get(domain, "#{path}?".concat(params.collect { |k,v| "#{k}=#{CGI::escape(v.to_s)}" }.join('&'))) unless params.nil?
return Net::HTTP.get(domain, path)
end
Site.all.each do |channel|
unless channel.domain.include?("autoforce") && channel.groupables.any?
http_get "blogs.yandex.ru", "/pings/", {status: "success", url: (channel.domain + "/sitemap.xml")}
http_get "google.com", "/webmasters/tools/ping", {sitemap: (channel.domain + "/sitemap.xml")}
http_get "bing.com", "/webmaster/ping.aspx", {siteMap: (channel.domain + "/sitemap.xml")}
puts " autodromo_log * RAKE SITEMAP * indexing #{channel.name}".black.on_green
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment