Skip to content

Instantly share code, notes, and snippets.

@AdamG
Created July 12, 2010 11:51
Show Gist options
  • Save AdamG/472390 to your computer and use it in GitHub Desktop.
Save AdamG/472390 to your computer and use it in GitHub Desktop.
class SitesPage(object):
def __init__(self, site, path):
self.site = site
self.path = path
self.load_data()
def load_data(self):
import gdata.sites.client
self.client = gdata.sites.client.SitesClient(
source="sitestest-v1", site=self.site)
feed = self.client.GetContentFeed(uri="{0}?path={1}".format(
self.client.MakeContentFeedUri(), self.path))
page = feed.GetWebpages()[0]
self.title = page.title.text
# Just pulled from a shell session. No easier way of doing
# without diving into lxml.xpath, and that's a whole 'nother
# can of worms.
p = page.content.children[0].children[0].children[0].children[0].children[0].children[0]
# Set up a list to wipe out all namespaces, I just want HTML.
_namespaced_elms = [p]
for elm in _namespaced_elms:
_namespaced_elms.extend(elm.children)
elm.namespace = ""
self.html = p.to_string()
def __unicode__(self):
return unicode(self.title)
def __repr__(self):
return "<SitesPage {0}{1} {2}>".format(
self.site, self.path, self.title)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment