Skip to content

Instantly share code, notes, and snippets.

@sekimura
Last active December 18, 2015 18:19
Show Gist options
  • Save sekimura/5825143 to your computer and use it in GitHub Desktop.
Save sekimura/5825143 to your computer and use it in GitHub Desktop.

Revisions

  1. sekimura revised this gist Jun 20, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -20,5 +20,5 @@ def resubmit(sitemap):


    if __name__ == '__main__':
    for sitemap in fetch_sitemaps():
    for sitemap in fetch_sitemaps(sys.argv[1]):
    resubmit(sitemap)
  2. sekimura created this gist Jun 20, 2013.
    24 changes: 24 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    import sys
    import urllib2
    import xml.etree.ElementTree as ET

    PING_URL = 'http://www.google.com/webmasters/tools/ping?sitemap=%s'


    def fetch_sitemaps(sitemapindex):
    response = urllib2.urlopen(sitemapindex)
    xml = response.read()
    root = ET.fromstring(xml)
    for loc in root.getiterator('{http://www.sitemaps.org/schemas/sitemap/0.9}loc'):
    yield loc.text


    def resubmit(sitemap):
    url = PING_URL % sitemap
    response = urllib2.urlopen(url)
    print response.read()


    if __name__ == '__main__':
    for sitemap in fetch_sitemaps():
    resubmit(sitemap)