def make_comment_dicts_by_ocr(topic_url, rv_comment): # type: (object, object) -> object # 组装回帖的参数 pic_url, pic_id = doubanutil.get_verify_code_pic(topic_url) verify_code = "" filepath, filename = "" if len(pic_url): pic_path = tools.save_pic_to_disk(pic_url) ##区分出path中的filename filepath = os.path.dirname(pic_path) filename = os.path.basename(pic_path) print("fname :[%s]" % filename, + "path [%s]" % filepath) # verify_code = wordrecognition.get_word_in_pic(pic_path) verify_code = util.OcrUtil.ocrImg(filepath, filepath) doubanutil.logger.info("in comment_topic(): verify_code:[%s]" % verify_code) comment_dict = { "ck": doubanutil.get_form_ck_from_cookie(), "rv_comment": rv_comment, "start": 0, "captcha-solution": verify_code, "captcha-id": pic_id, "submit_btn": u"发送" } return comment_dict
def make_comment_dict(topic_url, rv_comment): # 组装回帖的参数 from nltk.corpus import words pic_url, pic_id = doubanutil.get_verify_code_pic(topic_url) verify_code = "" while verify_code =='': if len(pic_url): verify_codeinword = False pic_path = tools.save_pic_to_disk(pic_url) rebuild_path=identify_code.recognize_url(pic_path) verify_code = wordrecognition.get_word_in_pic(rebuild_path) verify_code.replace('/','l') verify_code.replace('!', 'i') verify_code.replace(' ', '') verify_code.replace('.', '') if len(verify_code)>=4: if verify_code in words.words() or verify_code.lower() in words.words(): comment_dict = { "ck": doubanutil.get_form_ck_from_cookie(), "rv_comment": rv_comment, "start": 0, "captcha-solution": verify_code, "captcha-id": pic_id, "submit_btn": "发送" } verify_codeinword = True return comment_dict else: pic_url, pic_id = doubanutil.get_verify_code_pic(topic_url) print(pic_url) verify_code = "" else: pic_url, pic_id = doubanutil.get_verify_code_pic(topic_url) print(pic_url) verify_code = "" comment_dict = { "ck": doubanutil.get_form_ck_from_cookie(), "rv_comment": rv_comment, "start": 0, "captcha-solution": verify_code, "captcha-id": pic_id, "submit_btn": "发送" } return comment_dict
def make_comment_dict(topic_url, rv_comment): comment_dict = { "ck": doubanutil.get_form_ck_from_cookie(), "rv_comment": rv_comment, "start": 0, "submit_btn": u"发送" } return comment_dict
def make_comment_dict(topic_url, rv_comment): # 组装回帖的参数 pic_url, pic_id = doubanutil.get_verify_code_pic(topic_url) verify_code = "" if len(pic_url): pic_path = tools.save_pic_to_disk(pic_url) verify_code = wordrecognition.get_word_in_pic(pic_path) comment_dict = { "ck": doubanutil.get_form_ck_from_cookie(), "rv_comment": rv_comment, "start": 0, "captcha-solution": verify_code, "captcha-id": pic_id, "submit_btn": "加上去" } return comment_dict
def make_topic_dict(group_id, rev_title, rev_text): # 组装发帖需要的参数 topic_new_url = doubanurl.DOUBAN_GROUP + str(group_id) + "/new_topic" pic_url, pic_id = doubanutil.get_verify_code_pic(topic_new_url) verify_code = "" if len(pic_url): pic_path = tools.save_pic_to_disk(pic_url) verify_code = wordrecognition.get_word_in_pic(pic_path) topic_dict = { "ck": doubanutil.get_form_ck_from_cookie(), "rev_title": rev_title, "rev_text": rev_text, "captcha-solution": verify_code, "captcha-id": pic_id, "rev_submit": "好了,发言" } return topic_dict