Skip to content

Commit

Permalink
add 优化问卷获取逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
qxzg committed Apr 18, 2023
1 parent 5616fe7 commit 5e1f8b1
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,9 @@ def get_questionnaire_list():

questionnaire_count = req['html'].count('<tr>')
soup = BeautifulSoup(req['html'], features='lxml').find_all('td')

n = 0
valid_mark = 0
for j in range(questionnaire_count):
questionnaire_data = {}
n = n + 1
Expand All @@ -94,13 +96,17 @@ def get_questionnaire_list():
if link_data.string == "已过期" or link_data.string == "查看详情" or link_data.string is None:
continue
else:
valid_mark = 1
questionnaire_remain = questionnaire_remain + 1
link_info = link_data.a['onclick'][18:-2].split(',')
questionnaire_data['alreadyId'] = link_info[0]
questionnaire_data['grantId'] = link_info[1]
questionnaire_data['questionnaireId'] = link_info[2]
questionnaire_list.append(questionnaire_data)

if not valid_mark:
print("本页已无未填写的问卷")
return

def do_questionnaire(questionnaire_data: dict):
payload = \
Expand Down Expand Up @@ -146,7 +152,7 @@ def do_questionnaire(questionnaire_data: dict):
get_questionnaire_list()
# print(questionnaire_list)
if questionnaire_remain == 0:
input("你都填完了啊,没我什么事了,我走了")
input("你都填完了啊,没我什么事了,润了润了")
exit()
print("您还有%d个问卷未填(已排除已过期的问卷),请按回车键确认:" % questionnaire_remain)
n = 1
Expand Down

0 comments on commit 5e1f8b1

Please sign in to comment.