Exemple #1
0
 def run(self):
     update_data = {}
     try:
         self.top()
         self.confirm()
         self.con_two()
         # print('=========')
     except AttributeError:
         update_data = {"tid": self.LOG_DATA[7], "status": '2'}
         self.auPipe.update(tid=self.LOG_DATA[7], status='2')
     except IndexError:
         update_data = {"tid": self.LOG_DATA[7], "status": '2'}
         self.auPipe.update(tid=self.LOG_DATA[7], status='2')
         raise AutomationError("列表超出范围", "automation_login")
     except AutomationError as ae:
         if ae.errorinfo == '未检测到番号':
             update_data = {"tid": self.LOG_DATA[7], "status": '8'}
             self.auPipe.update(tid=self.LOG_DATA[7], status='8')
         elif ae.errorinfo == "未提交成功":
             update_data = {"tid": self.LOG_DATA[7], "status": '9'}
             self.auPipe.update(tid=self.LOG_DATA[7], status='9')
         else:
             raise AutomationError('登陆失效, 重新登陆...', "automation_login")
         ERRINFO(self.LOG_DATA[7], self.LOG_DATA[1],
                 "automation_login", ae.errorinfo)
     except Exception as e:
         update_data = {"tid": self.LOG_DATA[7], "status": '2'}
         self.auPipe.update(tid=self.LOG_DATA[7], status='2')
         # print('automation_login 出现错误...')
         ERRINFO(self.LOG_DATA[7], self.LOG_DATA[1], "automation_login", e)
         raise AutomationError(e, "automation_login")
     finally:
         return update_data
Exemple #2
0
    def search_info(self):
        # print('进入搜索信息搜索列表,并搜索指定ID')
        # print(self.FH)
        if self.FH:
            # print('检索信息-有番号查询')
            data = {
                'CODE': self.FH,
                'PAGE_VIEW_NUMBER': '0',
                'BTN_SEARCH_x': '検 索',
            }

            res = self.req.post(self.identity_list_url, data=data)
            reg = r'<a href="identity_info\.php\?IDENTITY_ID=(.*?)">{}</a>'.format(
                self.FH)
            self.identity_id = re.findall(reg, res.text)
            # print(f'检索成功, id: {self.identity_id}!执行撤回操作!')
        else:
            # 1、 进入搜索信息搜索列表,并搜索指定ID
            # print('检索信息-无番号查询')
            try:
                res = self.req.get(self.identity_list_url)
                if res.url == self.login_url:
                    raise AutomationError('登陆失效, 重新登陆...')
                self.identity_id = res.text.split(self.info, 1)[1].split(
                    '<tr class="', 1)[1].split('"', 1)[0][-7:]
                # print(f'检索成功, id: {self.identity_id}!执行撤回操作!')

            except Exception:
                try:
                    for i in range(1, 31):
                        ne = f'?p={i}&s=1&d=2'
                        url = self.identity_list_url + ne
                        res = self.req.get(url)
                        if res.url == self.login_url:
                            raise AutomationError('登陆失效...')
                        try:
                            self.identity_id = res.text.split(self.info, 1)[1].split(
                                '<tr class="', 1)[1].split('"', 1)[0][-7:]
                            # print(f'检索成功, id: {self.identity_id}!执行撤回操作!')
                            self.get_url = url
                            break
                        except Exception:
                            continue
                    else:
                        self.auPipe.update(
                            tid=self.LOG_DATA[7], submit_status='111')
                        return
                except Exception:
                    self.auPipe.update(
                        tid=self.LOG_DATA[7], submit_status='111')
        if not self.identity_id:
            self.auPipe.update(self.LOG_DATA[7], submit_status="111", pdf="")
        self.identity_id = self.identity_id[0]
Exemple #3
0
    def con_two(self):
        # print('in Login con_two')
        data = {
            "MAIL_STATUS": "0",
            "_PAGE_KEY": self._PAGE_KEY_2,
            "BTN_CHECK_SUBMIT_x": "登 録",
        }
        try:
            res = self.req.post(self.confirm_url, data=data)
        except Exception:
            return
            # print(e)

        if res.url == 'https://churenkyosystem.com/member/identity_edit.php?mode=add' and res.status_code == 200:
            if '完了画面' not in res.text:
                raise AutomationError("未提交成功")
            try:
                reg = r'受付番号(.*?)<'
                self.FH = re.findall(reg, res.text)[0][1:].strip()
                # print(f'\n\n===={self.FH}====\n\n')
            except Exception:
                pass
                # print(e)
            if self.LOG_DATA[9] is None or self.LOG_DATA[9] == self.LOG_DATA[3]:
                update_data = {
                    "tid": self.LOG_DATA[7], "submit_status": '211', "pdf": self.FH}
                self.auPipe.update(
                    tid=self.LOG_DATA[7], submit_status='211', pdf=self.FH)
            else:
                update_data = {
                    "tid": self.LOG_DATA[7], "submit_status": '222', "pdf": self.FH}
                self.auPipe.update(
                    tid=self.LOG_DATA[7], submit_status='222', pdf=self.FH)
        else:
            if res.url == self.login_url:
                raise AutomationError('登陆失效, 重新登陆...')

        # print('-' * 20, '\nthe info is OK\n', '-' * 20)
        # print('提交数据OK\n')
        try:
            with open(os.path.join(LOG_DIR, f'{DAY()}.json'), 'a') as f:
                log = {'提交': self.LOG_DATA, 'id': self.FH,
                       'time': strftime('%m/%d %H:%M:%S')}
                json.dump(log, f)
                f.write(',\n')
        except Exception:
            pass

        return update_data
Exemple #4
0
    def search_info(self):
        # print('进入搜索信息搜索列表,并搜索指定ID')
        # print(self.LOG_DATA[8])
        if self.LOG_DATA[8]:
            # print('检索信息-有番号查询')
            data = {
                'CODE': self.LOG_DATA[8],
                'PAGE_VIEW_NUMBER': '0',
                'BTN_SEARCH_x': '検 索',
            }

            res = self.req.post(self.identity_list_url, data=data)
            reg = r'<a href="identity_info\.php\?IDENTITY_ID=(.*?)">{}</a>'.format(
                self.LOG_DATA[8])
            self.identity_id = re.findall(reg, res.text)[0]
            # print('The Transmission first step to success!')
            # print(self.identity_id)
        else:
            # 1、 进入搜索信息搜索列表,并搜索指定ID
            # print('检索信息-无番号查询')
            try:
                res = self.req.get(self.identity_list_url)
                if res.url == self.login_url:
                    raise AutomationError('登陆失效...')
                self.identity_id = res.text.split(self.info, 1)[1].split(
                    '<tr class="', 1)[1].split('"', 1)[0][-7:]
                # print('The Transmission first step to success!')
                # print(self.identity_id)

            except Exception:
                for i in range(1, 21):
                    ne = '?p={}&s=1&d=2'.format(i)
                    url = self.identity_list_url + ne
                    res = self.req.get(url)
                    if res.url == self.login_url:
                        raise AutomationError('登陆失效...')
                    try:
                        self.identity_id = res.text.split(
                            self.info, 1)[1].split('<tr class="',
                                                   1)[1].split('"', 1)[0][-7:]
                        # print('The Transmission first step to success!')
                        self.get_url = url
                        break
                    except Exception:
                        continue
Exemple #5
0
 def confirm(self):
     # print('in login confirm')
     files = self.files_data()
     res = self.req.post(self.confirm_url, data=files)
     assert res.url != self.login_url
     if res.url == self.login_url:
         raise AutomationError('登陆失效...')
     reg = r'<input type="hidden" name="_PAGE_KEY" value="(.*?)" />'
     self._PAGE_KEY_2 = re.findall(reg, res.text)[0]
Exemple #6
0
 def run(self):
     sleep(1)
     try:
         self.search_info()
         sleep(1)
         self.undo()
     except AttributeError as ate:
         self.auPipe.update(tid=self.LOG_DATA[7], status='2')
         raise AutomationError(ate, "automation_undo")
     except IndexError:
         self.auPipe.update(tid=self.LOG_DATA[7], status='2')
         raise AutomationError("列表超出范围", "automation_undo")
     except AutomationError:
         raise AutomationError('登陆失效, 重新登陆...', "automation_undo")
     except Exception as e:
         # print('automation_undo 出现错误...')
         ERRINFO(self.LOG_DATA[7], self.LOG_DATA[1], "automation_undo", e)
         raise AutomationError(e, "automation_undo")
Exemple #7
0
    def undo(self):
        data = {
            'IDENTITY_ID': self.identity_id,
            'CANCEL_TYPE': random.choice(['2', '3'])
        }
        res = self.req.post(
            'https://churenkyosystem.com/member/set_cancel_identity.php', data=data)
        if res.url == self.login_url:
            raise AutomationError('登陆失效, 重新登录...')
        sleep(3)

        self.auPipe.update(tid=self.LOG_DATA[7], submit_status='111')
        # print('==========\n撤回请求成功!\n==========')

        with open(os.path.join(LOG_DIR, f'{DAY()}.json'), 'a') as f:
            log = {'撤销': self.LOG_DATA,
                   'id': self.LOG_DATA[-1], 'time': strftime('%m/%d %H:%M:%S')}
            json.dump(log, f)
            f.write(',\n')

        res = self.req.get('https://churenkyosystem.com/member/top.php')
        if res.url == self.login_url:
            raise AutomationError('登陆失效...')
Exemple #8
0
    def top(self):
        # print('in Login top')
        res = self.req.get(self.top_url)
        # print(res.url)
        if res.url == self.login_url:
            raise AutomationError('登陆失效...')
        # print('in Login top 2')
        res = self.req.get(self.add_url)
        assert res.url != self.login_url
        # print('in Login top 3')
        reg = r'<input type="hidden" name="_PAGE_KEY" value="(.*?)" />'
        page_key = re.findall(reg, res.text)
        # print(page_key)
        if len(page_key) == 0:
            raise AutomationError("_PAGE_KEY 没有")
        self._PAGE_KEY = page_key[0]

        # print('in Login top data')
        # 指定番号
        data = {
            'CHINA_AGENT_CODE': self.LOG_DATA[0]
        }

        res = self.req.post(self.agent_code_url, data=data)
        assert res.url != self.login_url
        # print(res.json())
        if res.url == self.login_url:
            raise AutomationError('登陆失效...')
        try:
            self.res_info = res.json()
            # print('指定番号检索完成(指定番号の検索完了)\n番号为(番号を):\n\t{0}\nID为(IDを):\n\t{1}\n'
            #       '公司名(会社名):\n\t{2}\n管辖公馆(管轄公館):\n\t{3}'
            #       ''.format(self.res_info['COMPANY_CODE'], self.res_info['CHINA_AGENT_ID'],
            #                 self.res_info['COMPANY_NAME'], self.res_info['DIPLOMAT_NAME']))
        except Exception:
            raise AutomationError('未检测到番号')
Exemple #9
0
 def run(self):
     try:
         self.search_info()
         self.upload_one()
         update_data = self.upload_two()
     except AttributeError as ate:
         update_data = {"tid": self.LOG_DATA[7], "status": '2'}
         self.auPipe.update(tid=self.LOG_DATA[7], status='2')
         raise AutomationError(ate, "automation_transmission")
     except IndexError:
         update_data = {"tid": self.LOG_DATA[7], "status": '2'}
         self.auPipe.update(tid=self.LOG_DATA[7], status='2')
         raise AutomationError("列表超出范围", "automation_transmission")
     except AutomationError:
         raise AutomationError('登陆失效, 重新登陆...', "automation_transmission")
     except Exception as e:
         update_data = {"tid": self.LOG_DATA[7], "status": '2'}
         self.auPipe.update(tid=self.LOG_DATA[7], status='2')
         # print('automation_transmission error...')
         ERRINFO(self.LOG_DATA[7], self.LOG_DATA[1],
                 "automation_transmission", e)
         raise AutomationError(e, "automation_transmission")
     finally:
         return update_data
Exemple #10
0
    def upload_one(self):

        url = self.identity_name_url.format(self.identity_id)

        res = self.req.get(url)
        reg = '<tr><th>受付番号</th><td colspan="3">(.*?)</td></tr>'
        self.FH = re.findall(reg, res.text)[0]

        # print('The Transmission second step is successful')
        url = self.i_nup_e_url.format(self.identity_id)
        res = self.req.get(url)
        if not self.FH:
            self.FH = re.findall(reg, res.text)[0]

        if res.url == self.login_url:
            raise AutomationError('登陆失效, 重新登陆...')
        # print('The Transmission third step is successful!\n')
        reg = '<input type="hidden" name="_PAGE_KEY" value="(.*?)" />'
        self._PAGE_KEY = re.findall(reg, res.text)[0]
    def down(self):
        url = 'https://churenkyosystem.com/member' + self.down_url
        url = url + self.identity_id if url[-1] == "=" else url
        res = self.req.get(url)
        if res.url == self.login_url:
            raise AutomationError('登陆失效...')
        file = {"file": res.content}

        data = {'tid': f'{self.LOG_DATA[7]}'}
        res = requests.post(INTERFACE, data=data, files=file)
        if res.json()['status'] == 1:
            self.auPipe.update(tid=self.LOG_DATA[7],
                               status='3',
                               submit_status='222')

            # print('-' * 20, '\nthe info is OK\n', '-' * 20)
            with open(os.path.join(LOG_DIR, f'{DAY()}.json'), 'a') as f:
                log = {'归国': "", 'time': strftime('%m/%d %H:%M:%S')}
                json.dump(log, f)
                f.write(',\n')
            # print('归国报告书下载OK\n')
        else:
            self.auPipe.update(tid=self.LOG_DATA[7], status='2')
    def identity_return(self):
        url = self.id_r_e_url.format(self.identity_id)

        res = self.req.get(url)
        if res.url == self.login_url:
            raise AutomationError('登陆失效...')

        # print('The Download second step is successful')
        reg = '<input type="hidden" value="(.*?)"  name="_PAGE_KEY" />'
        self._PAGE_KEY = re.findall(reg, res.text)[0]

        data = {
            "JAPAN_PREPARED": "",
            "CHINA_TEL": "",
            "CHINA_FAX": "",
            "CHINA_PREPARED": "",
            "GROUP_NAME": "",
            "NUMBER_OF_TOURISTS_MALE": "",
            "NUMBER_OF_TOURISTS_FEMALE": "",
            "TOURISTS_ADDRESS": "",
            "NUMBER_OF_ESCORT": "",
            "NUMBER_OF_GUIDE": "",
            "CHANGE_SCHEDULE_CONTENTS": "",
            "CHANGE_SCHEDULE_REASON": "",
            "TRANSLATOR_NAME": "",
            "TRANSLATOR_PREF": "",
            "TRANSLATOR_NUMBER": "",
            "TRANSLATOR_CONTACT": "",
            "JAPAN_ESCORT_NAME": "",
            "JAPAN_ESCORT_CONTACT": "",
            "JAPAN_ESCORT_DEPARTMENT": "",
            "CHINA_ESCORT_NAME": "",
            "CHINA_ESCORT_CONTACT": "",
            "CHINA_ESCORT_DEPARTMENT": "",
            "PASSENGER_NAME": "",
            "PASSENGER_ADDRESS": "",
            "PASSENGER_TEL": "",
            "PASSENGER_NUMBER": "",
            "PASSENGER_AREA": "",
            "FLIGHT_NUMBER": "",
            "DEPARTURE_PLACE": "",
            "DEPARTURE_TIME": "",
            "ARRIVAL_PLACE": "",
            "ARRIVAL_TIME": "",
            "_PAGE_KEY": self._PAGE_KEY,
            "BTN_CHECK_x": '確認'
        }

        res = self.req.post(url, data=data)
        if res.url == self.login_url:
            raise AutomationError('登陆失效...')
        reg = r'<input type="hidden" value="(.*?)"  name="_PAGE_KEY" />'
        self._PAGE_KEY = re.findall(reg, res.text)[0]
        # print('The Download third step is successful')

        data = {"_PAGE_KEY": self._PAGE_KEY, "BTN_CHECK_SUBMIT_x": '登 録'}
        res = self.req.post(url, data=data)
        if res.url == self.login_url:
            c = client.ClientLogin()
            c.run
            self.req = c.req
            res = self.req.get(url)

        # reg = r"window\.open\('\.(.*?)', '_blank'\);"

        self.down_url = res.text.split("window.open('.")[1].split(
            "', '_blank');")[0]