Created
April 9, 2018 14:09
-
-
Save ErvalhouS/0fefde39f0fa4ade981a863392b85513 to your computer and use it in GitHub Desktop.
A rake task to ping main search providers with updated sitemap.xml
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
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