Created
August 31, 2022 16:43
-
-
Save gangchen/9c3de7a8911843c975d15d26f053c974 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 其实用可用来问卷星上爬各种公开的带答案的问卷 | |
# 现在这个网址是广东省2022年PCR实验员资格考试的练习题问卷 | |
from requests_html import HTMLSession | |
wenjuanxing_URL = "https://ks.wjx.top/vm/QqNTNBr.aspx" | |
def parse_post_data(resp): | |
print(resp.html.links) | |
question_div = resp.html.find('#divQuestion', first=True) | |
questions = question_div.find('.ui-field-contain') | |
for q in questions: | |
title = q.find('.field-label', first=True).text | |
choices = q.find('.ui-checkbox') | |
choices = choices + q.find('.ui-radio') | |
print(title) | |
for choice in choices: | |
print(choice.text) | |
print("正确答案:") | |
for choice in choices: | |
correct_choice = choice.find('[ans="1"]', first=True) | |
if correct_choice is None: | |
continue | |
else: | |
print(correct_choice.text) | |
def main(): | |
session = HTMLSession() | |
resp = session.get(wenjuanxing_URL) | |
parse_post_data(resp) | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment