Skip to content

Instantly share code, notes, and snippets.

@alexpetralia
Last active September 25, 2016 15:40
Show Gist options
  • Save alexpetralia/919aa54619512705022100135e232914 to your computer and use it in GitHub Desktop.
Save alexpetralia/919aa54619512705022100135e232914 to your computer and use it in GitHub Desktop.
for survey_question, table in zip(survey_questions, tables):
rows = table.findAll('tr')#, {'class': 'parent-row'})
for row in rows:
if row.get('class') == ['parent-row']:
cells = row.findAll('td')
response = cells[2].get_text().strip()
confidence = cells[3].get_text().strip()
comment = cells[4].get_text().strip()
tmp_data = {
'survey_date': dtutil.parse(survey_date),
'topic_name': topic,
'topic_url': domain + handle,
'survey_question': survey_question,
'economist_name': cells[0].get_text().strip(),
'economist_url': domain + cells[0].a['href'],
'economist_headshot': domain + cells[0].img['src'],
'institution': cells[1].get_text().strip(),
'response': response,
'confidence': confidence,
'comment': comment,
}
data += [tmp_data]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment