Skip to content
This repository has been archived by the owner on Apr 1, 2021. It is now read-only.

Commit

Permalink
Merge pull request #77 from NKUST-ITC/hotfix#76
Browse files Browse the repository at this point in the history
修復#76 請假申請失敗的問題
  • Loading branch information
abc873693 authored Jan 20, 2020
2 parents 25d99c8 + 5c14240 commit 3684c2f
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/crawler/leave_crawler.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,8 +215,10 @@ def leave_submit(session, leave_data, proof_file=None, proof_file_name="test.jpg
req = session.post(url=main_url, data=form_data)
root = etree.HTML(req.text)
try:
if root.xpath("//script[@language='javascript']")[0].text.find('alert') >= 0:
return error_code.LEAVE_SUBMIT_WRONG_DATE # 日期不對//或是不再學期中
alert = root.xpath("//script[@language='javascript']")[0].text
if alert.find('alert') >= 0:
if alert.find('不在學期間') >= 0: # 延遲請假也會用alert
return error_code.LEAVE_SUBMIT_WRONG_DATE # 日期不對//或是不再學期中
except:
pass

Expand All @@ -226,7 +228,7 @@ def leave_submit(session, leave_data, proof_file=None, proof_file_name="test.jpg
global_form_data['ctl00$ContentPlaceHolder1$CK001$RadioButtonListOption'] = leave_data['leaveType']
time_code = root.xpath(
"//div[@id='ContentPlaceHolder1_CK001_UpdatePanel2']//tr")
if leave_data.get('delayReasonText', False):
if leave_data.get('delayReasonText', False) and req.text.find('延遲理由') > -1:
global_form_data['ctl00$ContentPlaceHolder1$CK001$TextBoxDelayReason'] = leave_data.get(
'delayReasonText', '')
need_click_button_data = []
Expand Down

0 comments on commit 3684c2f

Please sign in to comment.