fix wolfralpha scraping when a pod is empty

This commit is contained in:
Ryan Hitchman 2010-02-01 21:52:09 -07:00
parent 1dd86babc2
commit 30f6ead292
1 changed files with 6 additions and 1 deletions

View File

@ -22,7 +22,12 @@ def wolframalpha(inp):
pod_texts = []
for pod in pods:
heading = pod.find('h1/span').text_content().strip()
heading = pod.find('h1/span')
if heading is not None:
heading = text_content().strip()
else:
continue
results = []
for image in pod.xpath('div/div[@class="output"]/img'):
alt = image.attrib['alt'].strip()