Example #1
0
def run(session, question, ch=''):
    pull_xml(filename)
    current = Bank.from_xml(filename)
    if question:
        # if current == question:
        #     print('输入“n”或“N”退出!')
        #     return question
        # elif ch and ch in 'ABCD':
        if ch and ch in 'ABCD':
            question.answer = ch
            db_add(session, question)

    question = current
    print('\n%s\n%s' %
          ('-' * min(len(question.content) * 2, 120), question.content))
    bank = db_qeury(session, content=question.content)
    if bank:
        # items = [x for x in (bank.item1, bank.item2, bank.item3, bank.item4) if x]
        # index = ord(bank.answer)-65
        # if index < len(items):
        #     items[index] = f'{items[index]} <--- [{bank.answer}]'
        # options = '\n'.join(items)
        # print(f'\n{options}')
        print(f"\n手机提交答案后可直接回车 正确答案:  {bank.answer}\n")
        return question
    return search(question)
Example #2
0
def start(device, count=None):
    m_ad = Adble(device)
    m_db = Model()

    cfg = ConfigParser()
    cfg.read('./config.ini')
    if not count:
        count = cfg.getint('base', 'answer_count')
    elif 0 >= count:
        count = 65532
    else:
        pass
        
    delay_rand = cfg.getboolean('base', 'delay_rand')
    delay = 1
    for i in range(count):
        xml = m_ad.get_xml()
        question = Bank.from_xml(device)
        bank = m_db.query(content=question.content)
        if delay_rand: 
            delay = randint(1,6)

        if bank:
            index = ord(bank.answer)-65
            pos = complex(question.bounds.split(' ')[index])
            print(question)
            print(f"\n {delay} 秒自动提交答案:  {bank.answer}\n")
            if 0j == pos:
                t= threading.Thread(target=attention, args=('crossed.mp3',1))#创建线程
                t.start()
                sleep(5)
                continue
            else:
                sleep(delay)
                m_ad.tap(int(pos.real), int(pos.imag))
        else:
            t= threading.Thread(target=attention, args=('doubt.mp3',2))#创建线程
            t.start()
            headers = {
                'User-Agent': cfg.get('base', 'user_agent')
            }
            search(question, headers)
            ch = input('请输入:').upper()
            if ch and 'N' == ch:
                break
            if ch and ch in "ABCD":
                question.answer = ch
                m_db.add(question)
Example #3
0
def start(device, count, filename, database_uri, delay_seconds, user_agent):
    m_ad = Adble(device)
    m_db = Model(database_uri, 'data-dev')
    if 0 == delay_seconds:
        delay_rand = True
    else:
        delay_rand = False

    for i in range(count):
        xml = m_ad.get_xml(filename)
        question = Bank.from_xml(device)
        bank = m_db.query(content=question.content)
        if delay_rand:
            delay_seconds = randint(1, 6)

        if bank:
            index = ord(bank.answer) - 65
            pos = complex(question.bounds.split(' ')[index])
            print(question)
            print(f"\n {delay_seconds} 秒自动提交答案:  {bank.answer}\n")
            if 0j == pos:
                t = threading.Thread(target=attention,
                                     args=('crossed.mp3', 1))  #创建线程
                t.start()
                sleep(5)
                continue
            else:
                sleep(delay_seconds)
                m_ad.tap(int(pos.real), int(pos.imag))
        else:
            t = threading.Thread(target=attention,
                                 args=('doubt.mp3', 2))  #创建线程
            t.start()
            headers = {'User-Agent': user_agent}
            search(question, headers)
            ch = input('请输入:').upper()
            if ch and 'N' == ch:
                break
            if ch and ch in "ABCD":
                question.answer = ch
                m_db.add(question)
Example #4
0
def run(session, num=float('inf')):
    # t= threading.Thread(target=attention)#创建线程
    # t.setDaemon(True)#设置为后台线程,这里默认是False,设置为True之后则主线程不用等待子线程
    while num:
        num = num - 1
        pull_xml(filename)
        sleep(1)
        question = Bank.from_xml(filename)
        print('\n%s\n%s' %
              ('-' * min(len(question.content) * 2, 120), question.content))
        bank = db_qeury(session, content=question.content)
        delay = 1  # randint(3,5)
        if bank:
            index = ord(bank.answer) - 65
            pos = complex(question.bounds.split(' ')[index])
            if question.item1: print('A. %s' % question.item1)
            if question.item2: print('B. %s' % question.item2)
            if question.item3: print('C. %s' % question.item3)
            if question.item4: print('D. %s' % question.item4)
            print(f"\n {delay} 秒自动提交答案:  {bank.answer}\n")
            if 0j == pos:
                t = threading.Thread(target=attention,
                                     args=('crossed.mp3', 1))  #创建线程
                t.start()
                sleep(5)
                continue
            else:
                sleep(delay)
                tap_screen(int(pos.real), int(pos.imag))
        else:
            t = threading.Thread(target=attention,
                                 args=('doubt.mp3', 2))  #创建线程
            t.start()
            search(question)
            ch = input('请输入:').upper()
            if ch and 'N' == ch:
                break
            if ch and ch in "ABCD":
                question.answer = ch
                db_add(session, question)