Skip to content

Commit

Permalink
add test ocr
Browse files Browse the repository at this point in the history
  • Loading branch information
lili19 committed Jun 16, 2021
1 parent 021fd7f commit 0f05b0b
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
13 changes: 13 additions & 0 deletions client/cli.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import ctypes
import configparser
from crawler.__main__ import main
from crawler.imgtool import ocr
from PIL import Image
import os

def has_admin():
Expand All @@ -17,6 +19,17 @@ def has_admin():

parser = configparser.ConfigParser()
parser.read('config.ini', encoding="UTF-8")

test_ocr = parser.get('basic', 'test_ocr', fallback='False')
test_ocr = test_ocr.lower() == 'true'
if test_ocr:
if not os.path.isfile("test.png"):
ctypes.windll.user32.MessageBoxW(0, "当前目录下没有test.png", "测试文件不存在", 0)
exit(-1)
text = ocr(Image.open("test.png"))
ctypes.windll.user32.MessageBoxW(0, text, "识别结果", 0)
exit(0)

lock_input = parser.get('basic', 'lock_input', fallback='False')
print("lock input {}".format(lock_input))
is_admin = has_admin()
Expand Down
4 changes: 2 additions & 2 deletions client/crawler/wechatautomator.py
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@ def process_page(self, account_name, items, lastpage_clicked_titles, states,
def extract_read_count(self, fn=None):
self.browser_page_down(30)
# 初步定位
for i in range(20):
for i in range(30):
img_array = imgtool.snap_shot(self.browser.rectangle())
if fn:
bottom = imgtool.locate_content_bottom(img_array, fn+"_coarse_"+str(i))
Expand Down Expand Up @@ -547,7 +547,7 @@ def locate_user(self, user, retry=5):
articles = []
#states = [{'url': 'https://mp.weixin.qq.com/s/e7EJ2URIvuEXkLweRMNKLg'}]
states = []
result = automator.crawl_gongzhonghao("新智元", articles, max_pages=5, states=states,
result = automator.crawl_gongzhonghao("黄梅芦花庵", articles, max_pages=5, states=states,
detail=[], latest_date="2021-05-04", crawl_counter=True,
debug_ocr=True)
print(result)
Expand Down

0 comments on commit 0f05b0b

Please sign in to comment.