(userId, cookies, article_pointer, scores)
| 10 | |
| 11 | |
| 12 | def article(userId, cookies, article_pointer, scores): |
| 13 | try: |
| 14 | if scores["article_num"] < const.article_num_all or scores["article_time"] < const.article_time_all: |
| 15 | # driver_article = Mydriver(nohead=nohead) |
| 16 | driver_article = Mydriver(nohead=True) |
| 17 | # def article_stop_function(): |
| 18 | # driver_article.quit() |
| 19 | # threads.regist_stop_function(article_stop_function) |
| 20 | driver_article.get_url("https://www.xuexi.cn/notFound.html") |
| 21 | driver_article.set_cookies(cookies) |
| 22 | links = get_links.get_article_links() |
| 23 | try_count = 0 |
| 24 | readarticle_time = 0 |
| 25 | while True: |
| 26 | if scores["article_num"] < const.article_num_all and try_count < 10: |
| 27 | article_remain = const.article_num_all - scores["article_num"] |
| 28 | for i in range(article_pointer, article_pointer + article_remain): |
| 29 | driver_article.get_url(links[i]) |
| 30 | readarticle_time = 60 + random.randint(5, 15) |
| 31 | for j in range(readarticle_time): |
| 32 | if random.random() > 0.5: |
| 33 | driver_article.go_js('window.scrollTo(0, document.body.scrollHeight/120*{})'.format(j)) |
| 34 | print("\r文章数量学 xi 中,文章剩余{}篇,本篇剩余时间{}秒".format(article_pointer + article_remain - i, readarticle_time - j), end="") |
| 35 | time.sleep(1) |
| 36 | driver_article.go_js('window.scrollTo(0, document.body.scrollHeight)') |
| 37 | total, scores = show_score(cookies) |
| 38 | if scores["article_num"] >= const.article_num_all: |
| 39 | print("检测到文章数量分数已满,退出学 xi ") |
| 40 | break |
| 41 | article_pointer += article_remain |
| 42 | else: |
| 43 | user.save_article_index(userId, article_pointer) |
| 44 | break |
| 45 | try_count = 0 |
| 46 | while True: |
| 47 | if scores["article_time"] < const.article_time_all and try_count < 10: |
| 48 | num_time = 60 |
| 49 | driver_article.get_url(links[article_pointer - 1]) |
| 50 | remaining = (const.article_time_all - scores["article_time"]) * 1 * num_time |
| 51 | for i in range(remaining): |
| 52 | if random.random() > 0.5: |
| 53 | driver_article.go_js( |
| 54 | 'window.scrollTo(0, document.body.scrollHeight/{}*{})'.format(remaining, i)) |
| 55 | print("\r文章时长学 xi 中,文章总时长剩余{}秒".format(remaining - i), end="") |
| 56 | time.sleep(1) |
| 57 | if i % (60) == 0 and i != remaining: |
| 58 | total, scores = show_score(cookies) |
| 59 | if scores["article_time"] >= const.article_time_all: |
| 60 | print("检测到文章时长分数已满,退出学 xi ") |
| 61 | break |
| 62 | driver_article.go_js('window.scrollTo(0, document.body.scrollHeight)') |
| 63 | total, scores = show_score(cookies) |
| 64 | else: |
| 65 | break |
| 66 | if try_count < 10: |
| 67 | print("文章学 xi 完成") |
| 68 | else: |
| 69 | print("文章学 xi 出现异常,请检查 user/article_video_index.json 文件记录") |
nothing calls this directly
no test coverage detected