def get_msg(msg):
    if msg.type == 'Sharing':
      target = msg.url

      import requests
      import yagmail
      import getpass
      from pyquery import PyQuery
      from mymodule import d11_stats_word
      
      response = requests.get('target')

      document = PyQuery (response.text)
      content = document ('#js_content').text() 

      statList = d11_stats_word.stats_text(content)
      
      print(statList)

      cipin_list=[]
      cihui_list=[]
      for i in statList:
          cihui_list.append(i[0])
          cipin_list.append(i[1])
          print(cihui_list)
      matplt(cihui_list,cipin_list)
      my_friend.send_image('C:/Users/admin/frcy.png')
def reply_my_friend(msg):
    response = requests.get(msg.url)
    document = PyQuery(response.text)
    content = document('#js_content').text()
    #URL信息提取
    reply = sw.stats_text(content, 10)
    #return reply
    #print(reply)
    #np_list=np.array(result) #将文本处理结果转化为二维数组

    reply_dict = dict(reply)
    word = []
    number = []
    for i in reply_dict:
        word.append(i)
        number.append(reply_dict[i])

    plt.rcdefaults()
    fig, ax = plt.subplots()

    y = np.arange(len(word))
    error = np.random.rand(len(word))

    plt.rcParams['font.sans-serif'] = ['SimHei']  #将中文字体显现
    ax.barh(y, number, xerr=error, align='center', color='green')
    ax.set_yticks(y)
    ax.set_yticklabels(word)

    ax.invert_yaxis()
    ax.set_xlabel('出现次数')
    ax.set_title('分享文章词频统计')

    plt.savefig('day13.png')
    msg.reply_image('day13.png')
Esempio n. 3
0
def reply_my_friend(msg):
    response = requests.get(msg.url)   
    document = PyQuery(response.text)    
    content = document('#js_content').text()
    #URL信息提取
    reply = sw.stats_text(content,100)
    return reply
    print(reply)
Esempio n. 4
0
def stats(url):
    payload = dict(key1='value1', key2='value2')
    response = requests.get(url,data=payload)

    document = PyQuery(response.text)
    content = document('#js_content').text()

    Slist = d11_stats_word.stats_text(content)

    S1 = " ".join(str(i) for i in Slist)

    return S1

 
# sender = input('输入发件人邮箱:' '*****@*****.**')
# password = getpass.getpass('输入发件人邮箱密码:' 'pwfpmmgsajmjbghg')
# recipients = input('输入收件人邮箱:' '*****@*****.**')
# smtp = 'smtp.qq.com'

# yagmail.SMTP(sender,password,smtp).send(recipients,'19100105 liwanlsl',S1)
from mymodule import d11_stats_word
import yagmail
import getpass
import requests



# 获取公众号文件
payload = dict(key1='value1', key2='value2')
response = requests.get('https://mp.weixin.qq.com/s/pLmuGoc4bZrMNl7MSoWgiA',data=payload)


# 提取公众号正文

document = PyQuery(response.text)
content = document('#js_content').text()

Slist = d11_stats_word.stats_text(content)

S1 = " ".join(str(i) for i in Slist)

sender = input('输入发件人邮箱:' '*****@*****.**')
password = getpass.getpass('输入发件人邮箱密码:' 'fxlsojlzcddgbgjc')
recipients = input('输入收件人邮箱:' '*****@*****.**')
host = "smtp.qq.com"

yag = yagmail.SMTP(sender,password,"smtp.qq.com")

yag.send(recipients,'19100105 liwanlsl',S1)    

import yagmail
import getpass
import requests
from mymodule import d11_stats_word as sw

sender = input('Please input sender mailaddress:')
password = getpass.getpass('Please input sender mailcode:')
recipients = input('Please input recipients addresses:')


# 提取微信公众号正文
from pyquery import PyQuery
response = requests.get('https://mp.weixin.qq.com/s/pLmuGoc4bZrMNl7MSoWgiA')
document = PyQuery(response.text)
content = document('#js_content').text()
statString = str(sw.stats_text(content,100))

print('sender =', sender, 'password ='******'recipients =', recipients)
yag = yagmail.SMTP(sender, password, host='smtp.163.com')
yag.send(recipients, '自学营5群 zhiguodavid', statString)