今天面试有个问卷星的笔试题,但是无法复制题目内容。
所以爬取一下。
pip3 install requests_html
目标链接:https://ks.wjx.top/jq/55123312.aspx
import time
from requests_html import HTMLSession
wenjuanxing_ID = 55123312
wenjuanxing_URL = "https://ks.wjx.top/jq/{}.aspx".format(wenjuanxing_ID)
def parse_post_data(resp):
'''
解析出问题和选项
'''
questions = resp.html.find('fieldset', first=True).find('.div_question')
for i, q in enumerate(questions):
title = q.find('.div_title_question_all', first=True).text
choices = [t.text for t in q.find('label')]
print(title)
for choice in choices:
print(choice)
print(