26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
|
# File 'lib/sitemap_generator/helper.rb', line 26
def ping_search_engines(sitemap_index)
require 'open-uri'
index_location = CGI.escape(url_with_hostname(sitemap_index))
yahoo_app_id = SitemapGenerator::Sitemap.yahoo_app_id
{:google => "http://www.google.com/webmasters/sitemaps/ping?sitemap=#{index_location}",
:yahoo => "http://search.yahooapis.com/SiteExplorerService/V1/ping?sitemap=#{index_location}&appid=#{yahoo_app_id}",
:ask => "http://submissions.ask.com/ping?sitemap=#{index_location}",
:bing => "http://www.bing.com/webmaster/ping.aspx?siteMap=#{index_location}",
:sitemap_writer => "http://www.sitemapwriter.com/notify.php?crawler=all&url=#{index_location}"}.each do |engine, link|
begin
unless SitemapGenerator::Sitemap.yahoo_app_id == false
open(link)
puts "Successful ping of #{engine.to_s.titleize}" if verbose
end
rescue Timeout::Error, StandardError => e
puts "Ping failed for #{engine.to_s.titleize}: #{e.inspect}" if verbose
puts "Yahoo requires an 'AppID' for more than one ping per \"timeframe\", you can either:\n - remove yahoo from the ping list (config/sitemap.rb):\nSitemapGenerator::Sitemap.yahoo_app_id = false\n - or add your Yahoo AppID to the generator (config/sitemap.rb):\nSitemapGenerator::Sitemap.yahoo_app_id = \"my_app_id\"\nFor more information: http://developer.yahoo.com/search/siteexplorer/V1/updateNotification.html\n END\n end\n end\nend\n" if engine == :yahoo && verbose
|