本文整理汇总了Python中models.Question.responses方法的典型用法代码示例。如果您正苦于以下问题:Python Question.responses方法的具体用法?Python Question.responses怎么用?Python Question.responses使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Question
的用法示例。
在下文中一共展示了Question.responses方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: scrape_questions
# 需要导入模块: from models import Question [as 别名]
# 或者: from models.Question import responses [as 别名]
def scrape_questions(requester, course_id):
"""
Scrape all the questions about the course along with student responses
"""
questions = []
base_url = '/course_evaluation_reports/fas/view_comments.html'
all_questions_url = '{}?course_id={}'.format(base_url, course_id)
all_soup = requester.make_request(all_questions_url)
question_links = all_soup.select('#reportContent h3 a')
for q_link in question_links:
q = Question(question=q_link.text)
q_url = '/course_evaluation_reports/fas/{}'.format(q_link.attrs['href'])
q_soup = requester.make_request(q_url)
q.responses = [r.text.strip() for r in q_soup.select('.response p')]
questions.append(q)
return questions