Last active
December 18, 2015 18:19
-
-
Save sekimura/5825143 to your computer and use it in GitHub Desktop.
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
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(sys.argv[1]): | |
resubmit(sitemap) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment