From cba338ff1adbf8a1933fc2bd37eda0ba47a4ba35 Mon Sep 17 00:00:00 2001 From: Thom Neale Date: Wed, 17 Apr 2013 10:37:34 -0400 Subject: [PATCH] ME: fix legislator color photo bug --- openstates/me/legislators.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/openstates/me/legislators.py b/openstates/me/legislators.py index 0e4baa8328..de8cc06a87 100644 --- a/openstates/me/legislators.py +++ b/openstates/me/legislators.py @@ -91,7 +91,11 @@ def scrape_reps(self, chamber, term_name): # Try to get color photo from the dems' website. elif party == 'Democratic': xpath = '//a[contains(@href, "housedems")]/@href' - party_website_url = doc.xpath(xpath)[0] + + els = doc.xpath(xpath) + if els: + party_website_url = els[0] + try: party_website_html = self.urlopen(party_website_url) except scrapelib.HTTPError: