def print_others(msg):
    # print(msg.type, msg.text)
    if msg.type == 'Sharing':
        print('chat',msg.chat)
        print('sender',msg.sender)
        print(msg.text, msg.url)
        # 处理并返回
        text = request(msg.url)
        res = stats_text_cn(text,100)
        res =json.dumps(res,ensure_ascii=False)
        msg.reply(res)
    print(msg)
Пример #2
0
def print_others(msg):
    # print(msg.type, msg.text)
    if msg.type == 'Sharing':
        print('chat', msg.chat)
        print('sender', msg.sender)
        print(msg.text, msg.url)
        # 处理并返回
        text = request(msg.url)
        res = stats_text_cn(text, 100)
        print('res', res)
        print(res.keys(), '--------------------------', res.values())
        chart(list(res.keys()), list(res.values()))
        # res = json.dumps(res, ensure_ascii=False)
        img_path = path_file + '\\mymodule\\' + 're.png'
        print('img_path', img_path)
        msg.reply_image(img_path)
    #     pass
    print(msg)
# 1. 获取到网页内容
# 2. 使用以前写的词频统计
# 3. 发送email到自己的邮箱

from mymodule.stats_word import stats_text_cn
from mymodule.utils import request, send_email
import json
# print(r.status_code)

# print(r.headers['content-type'])

# print(r.encoding)
text = request('https://mp.weixin.qq.com/s/pLmuGoc4bZrMNl7MSoWgiA')

res = stats_text_cn(text, 0)
res = json.dumps(res, ensure_ascii=False)
send_email(res)

print(res)
# print(r.text)