Skip to content

Instantly share code, notes, and snippets.

@ckunte
Last active August 29, 2015 14:02
Show Gist options
  • Save ckunte/bb383275d1909cdebe71 to your computer and use it in GitHub Desktop.
Save ckunte/bb383275d1909cdebe71 to your computer and use it in GitHub Desktop.
#!/usr/bin/env python
# encoding: utf-8
"""
mapsite.py
2014-06-07: Created by ckunte.
2014-08-28: Updated to urllib3, and beautifulsoup4.
Requirements:
1. beautifulsoup4 module. (pip install beautifulsoup4)
2. A file named srvclst.txt with ping servers list.
"""
import bs4
import urllib3
import xmlrpclib
#--- Start edit: site details ---------------------
# For absolute links: SITEURL = ''
# For relative links: SITEURL = 'http://mysite.com'
SITEURL = 'http://ckunte.net'
SITETITLE = 'Chyetanya Kunte'
SITEMAP = 'http://ckunte.net/log/archive'
#--- End edit. ------------------------------------
def main():
servers = [line.strip() for line in open('srvclst.txt', 'r')]
http = urllib3.PoolManager()
html_page = http.urlopen('GET', SITEMAP, preload_content=False)
soup = bs4.BeautifulSoup(html_page)
for link in soup.find_all('a'):
title = SITETITLE + ": " + link.contents[0]
url = SITEURL + link.get('href')
for ps in servers:
remoteServer = xmlrpclib.Server(ps)
push = remoteServer.weblogUpdates.ping(title, url)
print title, push['message']
pass
pass
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment